{"id":32705580,"url":"https://github.com/zig-utils/zig-faker","last_synced_at":"2026-04-01T17:08:25.840Z","repository":{"id":320778673,"uuid":"1083241637","full_name":"zig-utils/zig-faker","owner":"zig-utils","description":"A high-performance, lightweight fake data generator. Generate realistic fake data for testing, prototyping, and development.","archived":false,"fork":false,"pushed_at":"2026-03-18T21:31:26.000Z","size":194,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-18T22:43:33.002Z","etag":null,"topics":["data","faker","library","mocker","zig"],"latest_commit_sha":null,"homepage":"","language":"Zig","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/zig-utils.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"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}},"created_at":"2025-10-25T16:15:21.000Z","updated_at":"2026-03-18T21:23:37.000Z","dependencies_parsed_at":"2025-10-25T21:22:21.832Z","dependency_job_id":"f02fa5cc-b329-4b16-915e-a3be70f20aeb","html_url":"https://github.com/zig-utils/zig-faker","commit_stats":null,"previous_names":["zig-utils/zig-faker"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/zig-utils/zig-faker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zig-utils%2Fzig-faker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zig-utils%2Fzig-faker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zig-utils%2Fzig-faker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zig-utils%2Fzig-faker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zig-utils","download_url":"https://codeload.github.com/zig-utils/zig-faker/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zig-utils%2Fzig-faker/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31290538,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-01T13:12:26.723Z","status":"ssl_error","status_checked_at":"2026-04-01T13:12:25.102Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["data","faker","library","mocker","zig"],"created_at":"2025-11-02T01:01:51.709Z","updated_at":"2026-04-01T17:08:25.832Z","avatar_url":"https://github.com/zig-utils.png","language":"Zig","readme":"# Zig Faker\n\nA high-performance, lightweight fake data generator for Zig, inspired by [ts-mocker](https://github.com/stacksjs/ts-mocker). Generate realistic fake data for testing, prototyping, and development.\n\n## Features\n\n- **High Performance**: Optimized for speed with minimal allocations\n- **Comprehensive Data**: 20+ major data categories with thousands of data points\n- **Extensive Locale Support**: 55 locales (27 base + 28 regional variants)\n- **Seeded Generation**: Reproducible random data with optional seeding\n- **Type Safe**: Fully typed Zig API\n- **Zero External Dependencies**: Pure Zig implementation\n- **Modular Design**: Use only what you need\n\n## Installation\n\nAdd zig-faker to your `build.zig.zon`:\n\n```zig\n.dependencies = .{\n    .@\"zig-faker\" = .{\n        .url = \"https://github.com/yourusername/zig-faker/archive/main.tar.gz\",\n        .hash = \"...\",\n    },\n},\n```\n\nThen in your `build.zig`:\n\n```zig\nconst zig_faker = b.dependency(\"zig-faker\", .{\n    .target = target,\n    .optimize = optimize,\n});\nexe.root_module.addImport(\"zig-faker\", zig_faker.module(\"zig-faker\"));\n```\n\n## Quick Start\n\n```zig\nconst std = @import(\"std\");\nconst Faker = @import(\"zig-faker\").Faker;\n\npub fn main() !void {\n    var gpa = std.heap.GeneralPurposeAllocator(.{}){};\n    defer _ = gpa.deinit();\n    const allocator = gpa.allocator();\n\n    // Initialize faker (no seed = random data)\n    var faker = Faker.init(allocator, null, null);\n\n    // Generate data\n    const name = try faker.person.fullName(.{});\n    defer allocator.free(name);\n\n    const email = try faker.internet.email();\n    defer allocator.free(email);\n\n    const phone = try faker.phone.phoneNumber();\n    defer allocator.free(phone);\n\n    std.debug.print(\"Name: {s}\\n\", .{name});\n    std.debug.print(\"Email: {s}\\n\", .{email});\n    std.debug.print(\"Phone: {s}\\n\", .{phone});\n}\n```\n\n## API Reference\n\n### Person Module\n\n```zig\n// First name with optional gender\nconst first = faker.person.firstName(.{ .gender = .male });\n\n// Last name\nconst last = faker.person.lastName();\n\n// Full name with options\nconst full = try faker.person.fullName(.{\n    .prefix = true,   // Add Mr./Mrs./etc.\n    .suffix = false,  // Add Jr./Sr./etc.\n    .gender = .female,\n});\ndefer allocator.free(full);\n\n// Name components\nconst prefix = faker.person.prefix();    // Mr., Mrs., Dr., etc.\nconst suffix = faker.person.suffix();    // Jr., Sr., III, etc.\nconst gender = faker.person.gender();    // Male, Female, Non-binary, etc.\nconst job = faker.person.jobTitle();     // Software Engineer, etc.\n```\n\n### Address Module\n\n```zig\n// City, state, country\nconst city = faker.address.city();\nconst state = faker.address.state();\nconst state_abbr = faker.address.stateAbbr();\nconst country = faker.address.country();\n\n// Street address\nconst street = try faker.address.streetAddress(.{\n    .use_full_address = false,\n});\ndefer allocator.free(street);\n\n// Full address\nconst address = try faker.address.fullAddress();\ndefer allocator.free(address);\n\n// Postal code\nconst zip = try faker.address.postalCode();\ndefer allocator.free(zip);\n\n// Direction\nconst direction = faker.address.direction(); // North, South, etc.\n```\n\n### Company Module\n\n```zig\n// Company name\nconst company = try faker.company.name();\ndefer allocator.free(company);\n\n// Company components\nconst suffix = faker.company.suffix();       // Inc, LLC, Corp, etc.\nconst industry = faker.company.industry();   // Technology, Finance, etc.\nconst buzzword = faker.company.buzzword();   // synergy, leverage, etc.\nconst descriptor = faker.company.descriptor(); // innovative, leading, etc.\n\n// Catch phrase\nconst phrase = try faker.company.catchPhrase();\ndefer allocator.free(phrase);\n```\n\n### Internet Module\n\n```zig\n// Email addresses\nconst email = try faker.internet.email();\ndefer allocator.free(email);\n\nconst free_email = try faker.internet.freeEmail();\ndefer allocator.free(free_email);\n\n// Domain components\nconst domain = try faker.internet.domainName();\ndefer allocator.free(domain);\n\nconst domain_word = faker.internet.domainWord();\nconst domain_suffix = faker.internet.domainSuffix();\n\n// URLs\nconst url = try faker.internet.url();\ndefer allocator.free(url);\n\n// Username\nconst username = try faker.internet.username();\ndefer allocator.free(username);\n\n// Password\nconst password = try faker.internet.password(8, 16); // min, max length\ndefer allocator.free(password);\n```\n\n### Phone Module\n\n```zig\n// Phone number (locale-specific format)\nconst phone = try faker.phone.phoneNumber();\ndefer allocator.free(phone);\n```\n\n### String Module\n\n```zig\n// UUID v4\nconst uuid = try faker.string.uuid();\ndefer allocator.free(uuid);\n\n// Nanoid (URL-friendly unique ID)\nconst nanoid = try faker.string.nanoid(21);\ndefer allocator.free(nanoid);\n\n// Random strings\nconst alphanum = try faker.string.alphanumeric(16);\ndefer allocator.free(alphanum);\n\nconst alpha = try faker.string.alpha(10);\ndefer allocator.free(alpha);\n\nconst numeric = try faker.string.numeric(8);\ndefer allocator.free(numeric);\n\nconst hex = try faker.string.hexadecimal(32);\ndefer allocator.free(hex);\n```\n\n## Seeded Generation\n\nFor reproducible random data (useful for testing):\n\n```zig\n// Same seed = same data\nvar faker1 = Faker.init(allocator, 12345, null);\nvar faker2 = Faker.init(allocator, 12345, null);\n\nconst name1 = faker1.person.firstName(.{});\nconst name2 = faker2.person.firstName(.{});\n// name1 == name2 (guaranteed)\n\n// Change seed at runtime\nfaker1.seed(54321);\nconst name3 = faker1.person.firstName(.{});\n// name3 will be different\n```\n\n## Locale Support\n\n```zig\nconst locales = @import(\"zig-faker\").locales;\n\n// Use specific locale (base locale)\nvar faker = Faker.init(allocator, null, \u0026locales.en);\n\n// Or use regional variant\nvar faker_us = Faker.init(allocator, null, \u0026locales.en_US);\nvar faker_uk = Faker.init(allocator, null, \u0026locales.en_GB);\n\n// Change locale at runtime\nfaker.setLocale(\u0026locales.es); // Switch to Spanish\n```\n\n### Available Locales (55 Total)\n\n**27 Base Locales:**\n- `af` (Afrikaans), `ar` (Arabic), `az` (Azerbaijani), `cs` (Czech), `da` (Danish)\n- `de` (German), `en` (English), `eo` (Esperanto), `es` (Spanish), `fa` (Persian)\n- `fi` (Finnish), `fr` (French), `he` (Hebrew), `hi` (Hindi), `it` (Italian)\n- `ja` (Japanese), `ko` (Korean), `nl` (Dutch), `no` (Norwegian), `pl` (Polish)\n- `pt` (Portuguese), `sv` (Swedish), `tl` (Tagalog), `tr` (Turkish), `uk` (Ukrainian)\n- `zh` (Chinese), `zu` (Zulu)\n\n**28 Regional Variants:**\n- **English (11)**: `en_US`, `en_GB`, `en_AU`, `en_CA`, `en_GH`, `en_HK`, `en_IE`, `en_IN`, `en_NG`, `en_ZA`\n- **German (3)**: `de_AT` (Austria), `de_CH` (Switzerland), `de_DE` (Germany)\n- **Spanish (2)**: `es_ES` (Spain), `es_MX` (Mexico)\n- **French (6)**: `fr_BE` (Belgium), `fr_CA` (Canada), `fr_CH` (Switzerland), `fr_FR` (France), `fr_LU` (Luxembourg), `fr_SN` (Senegal)\n- **Portuguese (3)**: `pt_BR` (Brazil), `pt_MZ` (Mozambique), `pt_PT` (Portugal)\n- **Chinese (2)**: `zh_CN` (China), `zh_TW` (Taiwan)\n- **African (2)**: `af_ZA` (Afrikaans - South Africa), `zu_ZA` (Zulu - South Africa)\n\nAll regional variants include localized:\n- City and state/province names\n- Postal code formats\n- Phone number formats\n- Domain suffixes and email providers\n- Appropriate locale-specific data\n\n## Data Categories\n\n### Person\n- First names (male, female, neutral)\n- Last names\n- Name prefixes/suffixes\n- Gender identities\n- Job titles\n\n### Address\n- Street names and numbers\n- Cities, states, countries\n- Postal codes\n- Directions\n- Full addresses\n\n### Company\n- Company names and suffixes\n- Industries\n- Business buzzwords\n- Descriptors\n- Catch phrases\n\n### Internet\n- Email addresses (custom and free providers)\n- Domain names\n- URLs\n- Usernames\n- Passwords\n\n### Phone\n- Phone numbers (locale-specific formats)\n\n### String Utilities\n- UUID v4 generation\n- Nanoid generation\n- Alphanumeric, alphabetic, numeric strings\n- Hexadecimal strings\n\n## Building and Testing\n\n```bash\n# Run tests\nzig build test\n\n# Run example\nzig build example\n\n# Run benchmarks\nzig build benchmark\n```\n\n## Performance\n\nZig Faker is designed for high performance with minimal memory allocations:\n\n- **UUID Generation**: Millions of operations per second\n- **Email Generation**: Millions of operations per second\n- **Name Generation**: Tens of millions of operations per second\n\nRun `zig build benchmark` to see performance on your system.\n\n## Memory Management\n\nZig Faker follows Zig's explicit memory management philosophy:\n\n- Functions that return const strings (e.g., `firstName()`, `city()`) return pointers to static data - no deallocation needed\n- Functions that return dynamic strings (e.g., `fullName()`, `email()`) allocate memory - you must free the result\n\n```zig\n// No deallocation needed (const string)\nconst first = faker.person.firstName(.{});\n\n// Must deallocate (dynamic string)\nconst full = try faker.person.fullName(.{});\ndefer allocator.free(full);\n```\n\n## Examples\n\n### Generate User Profile\n\n```zig\nconst profile = .{\n    .name = try faker.person.fullName(.{ .prefix = true }),\n    .email = try faker.internet.email(),\n    .phone = try faker.phone.phoneNumber(),\n    .address = try faker.address.fullAddress(),\n    .company = try faker.company.name(),\n    .job_title = faker.person.jobTitle(),\n};\n\ndefer allocator.free(profile.name);\ndefer allocator.free(profile.email);\ndefer allocator.free(profile.phone);\ndefer allocator.free(profile.address);\ndefer allocator.free(profile.company);\n```\n\n### Seed Database with Test Data\n\n```zig\nvar faker = Faker.init(allocator, 12345, null); // Seeded for reproducibility\n\nvar users = std.ArrayList(User).init(allocator);\ndefer users.deinit();\n\nfor (0..100) |_| {\n    const user = User{\n        .name = try faker.person.fullName(.{}),\n        .email = try faker.internet.email(),\n        .phone = try faker.phone.phoneNumber(),\n    };\n    try users.append(user);\n}\n```\n\n### Generate Test Fixtures\n\n```zig\ntest \"user registration\" {\n    var faker = Faker.init(std.testing.allocator, null, null);\n\n    const email = try faker.internet.email();\n    defer std.testing.allocator.free(email);\n\n    const password = try faker.internet.password(8, 16);\n    defer std.testing.allocator.free(password);\n\n    const result = try registerUser(email, password);\n    try std.testing.expect(result.success);\n}\n```\n\n## Roadmap\n\n- [x] ✅ Additional locales - **55 locales implemented!**\n- [x] ✅ More data categories - **20+ modules including Food, Animal, Sport, Music, etc.**\n- [x] ✅ Date/time generation\n- [x] ✅ Lorem ipsum text generation\n- [x] ✅ Color generation\n- [x] ✅ Financial data (credit cards, IBANs, Bitcoin/Ethereum addresses)\n- [x] ✅ Validation system with 12+ validators\n- [x] ✅ Weighted selection and realistic distributions\n- [ ] CLI tool for data generation\n- [ ] Advanced features (constraints, data relationships, templates)\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nMIT\n\n## Acknowledgments\n\nInspired by [ts-mocker](https://github.com/stacksjs/ts-mocker) - a blazing-fast TypeScript faker library.\n\n## Related Projects\n\n- [ts-mocker](https://github.com/stacksjs/ts-mocker) - TypeScript/JavaScript version\n- [@faker-js/faker](https://github.com/faker-js/faker) - Popular JavaScript faker library\n\n### Food Module\n\n```zig\n// Food items\nconst dish = faker.food.dish();           // Pizza, Burger, Sushi, etc.\nconst ingredient = faker.food.ingredient(); // Tomato, Onion, Garlic, etc.\nconst fruit = faker.food.fruit();         // Apple, Banana, Orange, etc.\nconst vegetable = faker.food.vegetable(); // Carrot, Broccoli, etc.\nconst meat = faker.food.meat();           // Chicken, Beef, Pork, etc.\nconst spice = faker.food.spice();         // Pepper, Salt, Paprika, etc.\n\n// Recipe name\nconst recipe = try faker.food.recipe();\ndefer allocator.free(recipe);\n```\n\n### Animal Module\n\n```zig\n// Animal breeds and species\nconst dog = faker.animal.dog();           // Labrador, German Shepherd, etc.\nconst cat = faker.animal.cat();           // Persian, Maine Coon, etc.\nconst bird = faker.animal.bird();         // Sparrow, Robin, Eagle, etc.\nconst fish = faker.animal.fish();         // Goldfish, Koi, Betta, etc.\nconst animal_type = faker.animal.type_(); // Mammal, Bird, Fish, etc.\n\n// Pet names\nconst pet_name = faker.animal.petName();  // Max, Bella, Charlie, etc.\n```\n\n### Date Module\n\n```zig\n// Timestamps\nconst timestamp = faker.date.timestamp();    // Random Unix timestamp\nconst past_date = faker.date.past(30);      // Within last 30 days\nconst future_date = faker.date.future(30);  // Within next 30 days\nconst recent = faker.date.recent();         // Within last 7 days\nconst soon = faker.date.soon();             // Within next 7 days\n\n// Date components\nconst weekday = faker.date.weekday();       // Monday, Tuesday, etc.\nconst month = faker.date.month();           // January, February, etc.\n\n// Formatted dates\nconst date_str = try faker.date.dateString(); // 2024-03-15\ndefer allocator.free(date_str);\n\nconst time_str = try faker.date.timeString(); // 14:30:45\ndefer allocator.free(time_str);\n\nconst iso = try faker.date.iso8601();        // 2024-03-15T14:30:45Z\ndefer allocator.free(iso);\n```\n\n### Number Module\n\n```zig\n// Basic numbers\nconst int_num = faker.number.int(1, 100);      // Random integer in range\nconst float_num = faker.number.float(0.0, 1.0); // Random float in range\nconst percent = faker.number.percentage(2);     // Random percentage\n\n// Special numbers\nconst prime_num = faker.number.prime(100);      // Random prime \u003c= 100\nconst even_num = faker.number.even(1, 100);     // Random even number\nconst odd_num = faker.number.odd(1, 100);       // Random odd number\n\n// Number formats\nconst binary = try faker.number.binary(8);      // 10110101\ndefer allocator.free(binary);\n\nconst octal = try faker.number.octal(6);        // 742531\ndefer allocator.free(octal);\n\nconst hex = try faker.number.hexadecimal(8);    // a3f5c2d1\ndefer allocator.free(hex);\n```\n\n### Color Module\n\n```zig\n// Color names\nconst color_name = faker.color.name();        // Red, Blue, Green, etc.\nconst css_color = faker.color.cssColor();     // aliceblue, antiquewhite, etc.\n\n// Color formats\nconst hex_color = try faker.color.hex();      // #FF5733\ndefer allocator.free(hex_color);\n\nconst rgb = try faker.color.rgb();            // rgb(255, 87, 51)\ndefer allocator.free(rgb);\n\nconst rgba = try faker.color.rgba();          // rgba(255, 87, 51, 0.8)\ndefer allocator.free(rgba);\n\nconst hsl = try faker.color.hsl();            // hsl(120, 50%, 50%)\ndefer allocator.free(hsl);\n\nconst hsla = try faker.color.hsla();          // hsla(120, 50%, 50%, 0.8)\ndefer allocator.free(hsla);\n\n// RGB array\nconst rgb_array = faker.color.rgbArray();     // [255, 87, 51]\n```\n\n### Lorem Module\n\n```zig\n// Words\nconst word = faker.lorem.word();              // lorem, ipsum, dolor, etc.\n\nconst words = try faker.lorem.words(5);       // 5 random words\ndefer allocator.free(words);\n\n// Sentences\nconst sentence = try faker.lorem.sentence();  // Random sentence with period\ndefer allocator.free(sentence);\n\nconst sentences = try faker.lorem.sentences(3); // 3 sentences\ndefer allocator.free(sentences);\n\n// Paragraphs\nconst paragraph = try faker.lorem.paragraph(); // Random paragraph\ndefer allocator.free(paragraph);\n\nconst paragraphs = try faker.lorem.paragraphs(2); // 2 paragraphs\ndefer allocator.free(paragraphs);\n\n// Other formats\nconst lines = try faker.lorem.lines(5);       // 5 lines of text\ndefer allocator.free(lines);\n\nconst slug = try faker.lorem.slug(3);         // lorem-ipsum-dolor\ndefer allocator.free(slug);\n\nconst text = try faker.lorem.text(100);       // ~100 characters of text\ndefer allocator.free(text);\n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzig-utils%2Fzig-faker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzig-utils%2Fzig-faker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzig-utils%2Fzig-faker/lists"}