{"id":50902958,"url":"https://github.com/stacksjs/ts-faker","last_synced_at":"2026-06-16T04:31:30.939Z","repository":{"id":317942388,"uuid":"1069457569","full_name":"stacksjs/ts-faker","owner":"stacksjs","description":"A performance-focused \u0026 lightweight faker / data mocking library with comprehensive locale support.","archived":false,"fork":false,"pushed_at":"2026-06-13T07:40:36.000Z","size":23956,"stargazers_count":5,"open_issues_count":5,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-14T23:21:48.022Z","etag":null,"topics":["faker","faker-library","fakerjs","generator","locales","mocker"],"latest_commit_sha":null,"homepage":"https://ts-mocker.netlify.app","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stacksjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["stacksjs","chrisbbreuer"],"open_collective":"stacksjs"}},"created_at":"2025-10-04T01:22:51.000Z","updated_at":"2026-06-10T11:50:05.000Z","dependencies_parsed_at":"2025-10-23T17:25:04.674Z","dependency_job_id":"10a38d9d-7caf-497c-8a80-cb45da4f5e0e","html_url":"https://github.com/stacksjs/ts-faker","commit_stats":null,"previous_names":["stacksjs/nanofaker","stacksjs/ts-mocker","stacksjs/ts-faker"],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/stacksjs/ts-faker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stacksjs%2Fts-faker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stacksjs%2Fts-faker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stacksjs%2Fts-faker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stacksjs%2Fts-faker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stacksjs","download_url":"https://codeload.github.com/stacksjs/ts-faker/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stacksjs%2Fts-faker/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34391702,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-16T02:00:06.860Z","response_time":126,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["faker","faker-library","fakerjs","generator","locales","mocker"],"created_at":"2026-06-16T04:31:30.083Z","updated_at":"2026-06-16T04:31:30.887Z","avatar_url":"https://github.com/stacksjs.png","language":"TypeScript","funding_links":["https://github.com/sponsors/stacksjs","https://github.com/sponsors/chrisbbreuer","https://opencollective.com/stacksjs"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\u003cimg src=\".github/art/cover.jpg\" alt=\"Social Card of this repo\"\u003e\u003c/p\u003e\n\n[![npm version][npm-version-src]][npm-version-href]\n[![GitHub Actions][github-actions-src]][github-actions-href]\n[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)\n\u003c!-- [![npm downloads][npm-downloads-src]][npm-downloads-href] --\u003e\n\u003c!-- [![Codecov][codecov-src]][codecov-href] --\u003e\n\n# ts-mocker\n\nA performance-focused and lightweight faker library for TypeScript with comprehensive locale support.\n\n## Features\n\n- ⚡️ **Performance-focused** - Built with speed and efficiency in mind\n- 🌍 **Multi-locale Support** - Complete translations for 28 languages with 22+ regional variants:\n  - Afrikaans _(af)_, Arabic _(ar)_, Azerbaijani _(az)_, Czech _(cs)_, Danish _(da)_, German _(de)_, English _(en)_, Esperanto _(eo)_, Spanish _(es)_, Persian/Farsi _(fa)_, Finnish _(fi)_, French _(fr)_, Hebrew _(he)_, Hindi _(hi)_, Italian _(it)_, Japanese _(ja)_, Korean _(ko)_, Dutch _(nl)_, Norwegian _(no)_, Polish _(pl)_, Portuguese _(pt)_, Swedish _(sv)_, Filipino _(tl)_, Turkish _(tr)_, Ukrainian _(uk)_, Chinese Simplified _(zh-cn)_, Chinese Traditional _(zh-tw)_, Zulu _(zu)_\n  - Plus regional variants: `en-us`, `en-gb`, `en-ca`, `en-ie`, `en-in`, `en-za`, `en-gh`, `en-ng`, `en-hk`, `fr-ca`, `fr-ch`, `fr-be`, `fr-lu`, `fr-sn`, `de-at`, `de-ch`, `es-mx`, `pt-mz`, `af-za`, `zu-za`, and more!\n- 📦 **Lightweight** - Minimal dependencies and small bundle size\n- 💪 **Fully Typed** - Written in TypeScript with comprehensive type definitions\n- 🎯 **Comprehensive Data** - 16+ data categories including:\n  - Person _(names, job titles, genders)_\n  - Address _(streets, cities, countries)_\n  - Company _(names, industries, buzzwords)_\n  - Internet _(emails, domains)_\n  - Phone numbers _(numbers)_\n  - Food _(dishes, ingredients, cuisines)_\n  - Animals _(dogs, cats, birds, fish, etc.)_\n  - Sports _(teams, athletes)_\n  - Music _(genres, artists, songs)_\n  - Commerce _(products, colors, materials)_\n  - Books _(titles, authors, publishers)_\n  - Vehicles _(manufacturers, models, types)_\n  - Words _(adjectives, verbs, nouns, etc.)_\n  - Hacker/Tech _(abbreviations, phrases)_\n  - System _(file names, file types)_\n  - Science _(elements, units, constants)_\n\n## Installation\n\n```bash\n# npm\nnpm install ts-mocker\n\n# pnpm\npnpm add ts-mocker\n\n# bun\nbun add ts-mocker\n\n# yarn\nyarn add ts-mocker\n```\n\n## Usage\n\n### Basic Usage\n\n```typescript\nimport { faker } from 'ts-mocker'\n\n// Generate random data with default locale (English)\nconst name = faker.person.fullName()\nconst email = faker.internet.email()\nconst address = faker.address.city()\n\nconsole.log(name) // \"John Doe\"\nconsole.log(email) // \"john.doe@example.com\"\nconsole.log(address) // \"New York\"\n```\n\n### Advanced Features\n\nts-mocker includes powerful advanced data generation features:\n\n```typescript\nimport { faker, globalProviderRegistry, ValidationRules, WeightedSelections } from 'ts-mocker'\n\n// Conditional generation with constraints\nconst maleName = faker.person.firstNameAdvanced({\n  constraints: { gender: 'male' }\n})\n\n// Weighted selection for realistic distribution\nconst commonName = faker.person.firstNameAdvanced({\n  weighted: WeightedSelections.commonFirstNames\n})\n\n// Data validation\nconst validatedName = faker.person.firstNameAdvanced({\n  validation: {\n    rules: [{ validator: ValidationRules.name }],\n    strict: false\n  }\n})\n\n// Realistic relationships\nconst family = faker.person.family({\n  constraints: { country: 'United States' },\n  size: 4\n})\nconst customProvider = {\n  name: 'Tech Company Generator',\n  category: 'company',\n  version: '1.0.0',\n  generate: () =\u003e 'Cloud Tech Solutions'\n}\nglobalProviderRegistry.register(customProvider)\n```\n\nSee [Advanced Features Documentation](docs/advanced-features.md) for complete details.\n\n### Using Different Locales\n\n```typescript\nimport { faker } from 'ts-mocker'\n\n// Set locale globally\nfaker.setLocale('es') // Spanish\nconsole.log(faker.person.fullName()) // \"María García\"\n\n// Or create a new instance with a specific locale\nconst spanishFaker = new Faker({ locale: 'es' })\nconst japaneseFaker = new Faker({ locale: 'ja' })\nconst chineseSimplifiedFaker = new Faker({ locale: 'zh-cn' })\nconst chineseTraditionalFaker = new Faker({ locale: 'zh-tw' })\n\nconsole.log(spanishFaker.person.fullName()) // \"Carlos López\"\nconsole.log(japaneseFaker.person.fullName()) // \"田中太郎\"\nconsole.log(chineseSimplifiedFaker.person.fullName()) // \"王伟\"\nconsole.log(chineseTraditionalFaker.person.fullName()) // \"陳小明\"\n\n// Regional variants provide localized data\nconst usFaker = new Faker({ locale: 'en-us' })\nconst ukFaker = new Faker({ locale: 'en-gb' })\nconst canadianFrenchFaker = new Faker({ locale: 'fr-ca' })\n\nconsole.log(usFaker.address.city()) // \"New York\"\nconsole.log(ukFaker.address.city()) // \"London\"\nconsole.log(canadianFrenchFaker.address.city()) // \"Montréal\"\n```\n\n### Available Locales\n\n- `af` - Afrikaans\n- `ar` - Arabic\n- `az` - Azerbaijani\n- `cs` - Czech\n- `da` - Danish\n- `de` - German\n- `en` - English\n- `eo` - Esperanto\n- `es` - Spanish\n- `fa` - Persian/Farsi\n- `fi` - Finnish\n- `fr` - French\n- `he` - Hebrew\n- `hi` - Hindi\n- `it` - Italian\n- `ja` - Japanese\n- `ko` - Korean\n- `nl` - Dutch\n- `no` - Norwegian\n- `pl` - Polish\n- `pt` - Portuguese\n- `sv` - Swedish\n- `tl` - Filipino\n- `tr` - Turkish\n- `uk` - Ukrainian\n- `zh-cn` - Chinese (Simplified)\n- `zh-tw` - Chinese (Traditional)\n- `zu` - Zulu\n\n#### Regional Variants\n\nMany languages also have regional variants with localized data for specific countries:\n\n**English Variants:**\n\n- `en-us` - English (United States)\n- `en-gb` - English (United Kingdom)\n- `en-ca` - English (Canada)\n- `en-ie` - English (Ireland)\n- `en-in` - English (India)\n- `en-za` - English (South Africa)\n- `en-gh` - English (Ghana)\n- `en-ng` - English (Nigeria)\n- `en-hk` - English (Hong Kong)\n\n**French Variants:**\n\n- `fr-ca` - French (Canada)\n- `fr-ch` - French (Switzerland)\n- `fr-be` - French (Belgium)\n- `fr-lu` - French (Luxembourg)\n- `fr-sn` - French (Senegal)\n\n**German Variants:**\n\n- `de-at` - German (Austria)\n- `de-ch` - German (Switzerland)\n\n**Spanish Variants:**\n\n- `es-mx` - Spanish (Mexico)\n\n**Portuguese Variants:**\n\n- `pt-mz` - Portuguese (Mozambique)\n\n**Afrikaans Variants:**\n\n- `af-za` - Afrikaans (South Africa)\n\n**Zulu Variants:**\n\n- `zu-za` - Zulu (South Africa)\n\nThese regional variants include country-specific data such as local cities, addresses, phone formats, and cultural references.\n\n### API Examples\n\n```typescript\nimport { faker } from 'ts-mocker'\n\n// Person\nfaker.person.firstName() // Random first name\nfaker.person.firstName({ gender: 'male' }) // Random male first name\nfaker.person.firstName({ gender: 'female' }) // Random female first name\nfaker.person.firstName({ gender: 'neutral' }) // Random neutral first name\nfaker.person.firstNameMale() // Random male first name\nfaker.person.firstNameFemale() // Random female first name\nfaker.person.firstNameNeutral() // Random neutral first name\nfaker.person.lastName() // Random last name\nfaker.person.fullName() // Random full name\nfaker.person.fullName({ gender: 'male' }) // Random full name with male first name\nfaker.person.fullName({ gender: 'female' }) // Random full name with female first name\nfaker.person.fullName({ prefix: true }) // Random full name with prefix\nfaker.person.fullName({ suffix: true }) // Random full name with suffix\nfaker.person.gender() // Random gender\nfaker.person.jobTitle() // Random job title\nfaker.person.prefix() // Random prefix (Mr., Mrs., etc.)\nfaker.person.suffix() // Random suffix (Jr., Sr., etc.)\n\n// Address\nfaker.address.street() // Random street name\nfaker.address.city() // Random city\nfaker.address.state() // Random state/province\nfaker.address.country() // Random country\nfaker.address.zipCode() // Random ZIP/postal code\nfaker.address.direction() // Random direction (North, South, etc.)\n\n// Company\nfaker.company.name() // Random company name\nfaker.company.industry() // Random industry\nfaker.company.buzzword() // Random business buzzword\n\n// Internet\nfaker.internet.email() // Random email address\nfaker.internet.domainName() // Random domain name\nfaker.internet.url() // Random URL\n\n// Phone\nfaker.phone.number() // Random phone number\n\n// Food\nfaker.food.dish() // Random dish name\nfaker.food.ingredient() // Random ingredient\nfaker.food.cuisine() // Random cuisine type\nfaker.food.dessert() // Random dessert\nfaker.food.fruit() // Random fruit\nfaker.food.vegetable() // Random vegetable\nfaker.food.meat() // Random meat\nfaker.food.spice() // Random spice\n\n// Animal\nfaker.animal.dog() // Random dog breed\nfaker.animal.cat() // Random cat breed\nfaker.animal.bird() // Random bird species\nfaker.animal.fish() // Random fish species\nfaker.animal.horse() // Random horse breed\nfaker.animal.rabbit() // Random rabbit breed\nfaker.animal.insect() // Random insect\n\n// Sport\nfaker.sport.sport() // Random sport name\nfaker.sport.team() // Random team name\nfaker.sport.athlete() // Random athlete name\n\n// Music\nfaker.music.genre() // Random music genre\nfaker.music.artist() // Random artist name\nfaker.music.song() // Random song title\nfaker.music.instrument() // Random instrument\n\n// Commerce\nfaker.commerce.product() // Random product name\nfaker.commerce.adjective() // Random product adjective\nfaker.commerce.material() // Random material\nfaker.commerce.department() // Random department\nfaker.commerce.color() // Random color\n\n// Book\nfaker.book.title() // Random book title\nfaker.book.author() // Random author name\nfaker.book.publisher() // Random publisher\nfaker.book.genre() // Random book genre\nfaker.book.series() // Random book series\nfaker.book.review() // Random book review\n\n// Vehicle\nfaker.vehicle.manufacturer() // Random vehicle manufacturer\nfaker.vehicle.model() // Random vehicle model\nfaker.vehicle.type() // Random vehicle type\nfaker.vehicle.fuel() // Random fuel type\nfaker.vehicle.bicycle() // Random bicycle type\n\n// Word\nfaker.word.adjective() // Random adjective\nfaker.word.adverb() // Random adverb\nfaker.word.conjunction() // Random conjunction\nfaker.word.interjection() // Random interjection\nfaker.word.noun() // Random noun\nfaker.word.preposition() // Random preposition\nfaker.word.verb() // Random verb\n\n// Hacker/Tech\nfaker.hacker.abbreviation() // Random tech abbreviation\nfaker.hacker.adjective() // Random tech adjective\nfaker.hacker.noun() // Random tech noun\nfaker.hacker.verb() // Random tech verb\nfaker.hacker.ingverb() // Random tech -ing verb\nfaker.hacker.phrase() // Random tech phrase\n\n// System\nfaker.system.fileName() // Random file name\nfaker.system.fileType() // Random file type\n\n// Science\nfaker.science.chemicalElement() // Random chemical element\nfaker.science.unit() // Random unit of measurement\nfaker.science.constant() // Random scientific constant\nfaker.science.field() // Random scientific field\n```\n\n## Command Line Interface\n\nts-mocker includes a powerful CLI for generating fake data from the terminal.\n\n### Installation\n\n```bash\n# Global installation\nnpm install -g ts-mocker\n\n# Or use with npx\nnpx ts-mocker [command]\n```\n\n### Quick Examples\n\n```bash\n# Generate a random name\nts-mocker generate person fullName\n\n# Generate 5 emails in Spanish\nts-mocker generate internet email --locale es --count 5\n\n# Generate 10 test users as JSON\nts-mocker batch 10\n\n# List all available categories\nts-mocker categories\n\n# List methods for a category\nts-mocker methods food\n```\n\n### Available Commands\n\n- `generate \u003ccategory\u003e \u003cmethod\u003e` - Generate random data\n- `batch \u003ccount\u003e` - Generate multiple complete records\n- `categories` - List all available categories\n- `methods \u003ccategory\u003e` - List methods for a category\n- `locales` - List all supported locales\n- `seed \u003cseed\u003e` - Generate reproducible data with a seed\n- `version` - Show version\n\n### Options\n\n- `--locale \u003clocale\u003e` - Use a specific locale (af, ar, az, cs, da, de, en, eo, es, fa, fi, fr, he, hi, it, ja, ko, nl, no, pl, pt, sv, tl, tr, uk, zh-cn, zh-tw, zu)\n- `--count \u003ccount\u003e` - Number of items to generate\n- `--seed \u003cseed\u003e` - Seed for reproducible results\n- `--json` - Output as JSON\n- `--template \u003ctemplate\u003e` - Template for batch: user, product, address, company\n\n### More Examples\n\n```bash\n# Reproducible data with seed\nts-mocker generate person fullName --seed 12345\n\n# Generate products in JSON\nts-mocker batch 5 --template product --json\n\n# Generate Japanese food items\nts-mocker generate food dish --locale ja --count 10\n\n# Save to file\nts-mocker batch 100 --template user \u003e users.json\n```\n\nSee the [CLI documentation](https://ts-mocker.stacksjs.org/cli) for complete details.\n\n## Performance Benchmarks\n\nts-mocker is designed for performance and efficiency:\n\n**Performance:**\n\n- ✅ **9 out of 9 benchmarks won**\n- ⚡ **9.28x faster than @faker-js/faker** on average\n- 🚀 **34.04M ops/s** for country generation\n- 🔑 **20.50M ops/s** for UUID generation (41.2x faster!)\n- 📧 **10.44M ops/s** for email generation (15.5x faster!)\n- 📊 **6.90ms** to generate 10,000 complex user objects\n\n**Package Size:**\n\n- 📦 **174 KB** published (core package only)\n- 🎯 **24.7x smaller than @faker-js/faker** (4.29 MB)\n- 🪶 **38 files** vs 231 in @faker-js/faker\n- 🔌 **Modular locales** - install only what you need\n\n### Quick Comparison\n\n| Operation | ts-mocker | @faker-js/faker | Speedup |\n|-----------|-----------|-----------------|---------|\n| UUID Generation | 20.50M ops/s | 497.69K ops/s | **41.2x faster** |\n| Full Name Generation | 24.76M ops/s | 678.37K ops/s | **36.5x faster** |\n| Country Generation | 34.04M ops/s | 1.05M ops/s | **32.4x faster** |\n| Email Generation | 10.44M ops/s | 674.02K ops/s | **15.5x faster** |\n| Complex Objects (10k) | 6.90ms | 64.04ms | **9.3x faster** |\n\n### Running Benchmarks\n\n```bash\n# Run all benchmarks\nbun run bench\n\n# Results are compared against\n# - @faker-js/faker\n# - chance\n# - casual\n# - @ngneat/falso\n```\n\n**Detailed Documentation:**\n\n- 📊 [BENCHMARKS.md](./BENCHMARKS.md) - Complete performance results and methodology\n\n## Testing\n\n```bash\nbun test\n```\n\n## Development\n\n```bash\n# Install dependencies\nbun install\n\n# Run tests\nbun test\n\n# Build the library\nbun run build\n\n# Lint code\nbun run lint\n```\n\n## Changelog\n\nPlease see our [releases](https://github.com/stacksjs/ts-mocker/releases) page for more information on what has changed recently.\n\n## Contributing\n\nWe welcome contributions! Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.\n\n## Community\n\nFor help, discussion about best practices, or any other conversation that would benefit from being searchable:\n\n[Discussions on GitHub](https://github.com/stacksjs/ts-mocker/discussions)\n\nFor casual chit-chat with others using this package:\n\n[Join the Stacks Discord Server](https://discord.gg/stacksjs)\n\n## Postcardware\n\n“Software that is free, but hopes for a postcard.” We love receiving postcards from around the world showing where Stacks is being used! We showcase them on our website too.\n\nOur address: Stacks.js, 12665 Village Ln #2306, Playa Vista, CA 90094, United States 🌎\n\n## Sponsors\n\nWe would like to extend our thanks to the following sponsors for funding Stacks development. If you are interested in becoming a sponsor, please reach out to us.\n\n- [JetBrains](https://www.jetbrains.com/)\n- [The Solana Foundation](https://solana.com/)\n\n## License\n\nThe MIT License (MIT). Please see [LICENSE](LICENSE.md) for more information.\n\nMade with 💙\n\n\u003c!-- Badges --\u003e\n[npm-version-src]: https://img.shields.io/npm/v/ts-mocker?style=flat-square\n[npm-version-href]: https://npmjs.com/package/ts-mocker\n[github-actions-src]: https://img.shields.io/github/actions/workflow/status/stacksjs/ts-mocker/ci.yml?style=flat-square\u0026branch=main\n[github-actions-href]: https://github.com/stacksjs/ts-mocker/actions?query=workflow%3Aci\n\n\u003c!-- [codecov-src]: https://img.shields.io/codecov/c/gh/stacksjs/ts-mocker/main?style=flat-square\n[codecov-href]: https://codecov.io/gh/stacksjs/ts-mocker --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstacksjs%2Fts-faker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstacksjs%2Fts-faker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstacksjs%2Fts-faker/lists"}