Skip to content

About

Seeded fake-data generator CLI: schema-driven synthetic datasets in JSON, JSONL and CSV

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

FakerLite

A seeded fake-data generator CLI. Describe the shape of a record once, as a small JSON schema, and FakerLite produces as many synthetic records as you ask for — in JSON, JSONL, or CSV. Useful for seeding a dev database, building test fixtures, demos, and load tests.

fakerlite generate --schema examples/users.schema.json --count 100 --seed 42 --format jsonl --out users.jsonl
{"id": "9f2c…", "first_name": "Maya", "last_name": "Novak", "email": "maya.novak@example.com", "age": 34, "is_active": true, "city": "Oslo", "tags": ["user"]}
{"id": "41ab…", "first_name": "Omar", "last_name": "Haddad", "email": "omar.haddad@example.com", "age": 51, "is_active": true, "city": "Lagos", "tags": ["guest", "user"]}

Why seeded?

The same seed always produces byte-identical output, so generated fixtures are reproducible: check the schema and the seed into your repo and anyone can regenerate the exact same dataset. Change the seed, get a fresh dataset.

Quick start

pip install .
fakerlite init                       # write an example schema.json
fakerlite types                      # list every field type
fakerlite validate --schema schema.json
fakerlite generate --schema schema.json --count 50 --seed 7 --format csv --out data.csv

Schema

A schema is a JSON object with a fields mapping. Each field has a type plus whatever options that type takes:

{
  "fields": {
    "id":         {"type": "uuid"},
    "first_name": {"type": "first_name"},
    "last_name":  {"type": "last_name"},
    "email":      {"type": "template", "template": "{first_name}.{last_name}@example.com"},
    "age":        {"type": "int", "min": 18, "max": 65},
    "is_active":  {"type": "bool", "p": 0.8},
    "city":       {"type": "city"},
    "tags":       {"type": "list",
                   "item": {"type": "pick", "values": ["admin", "user", "guest"]},
                   "min": 1, "max": 3},
    "address":    {"type": "object",
                   "fields": {"street": {"type": "address"}, "country": {"type": "country"}}}
  }
}

Run fakerlite types for the full list — 30 types, including name, username, ipv4/ipv6, date/datetime/timestamp, sentence, paragraph, hex, url, and company. Two types compose the rest:

  • object — a nested record with its own fields.
  • list — an array of item values, min..max long.
  • template — a string with {field} placeholders filled from values already generated in the same record (handy for derived emails and slugs).
  • ref — copy the value of another field in the same record.

Design decisions

  1. One seeded RNG stream. The generator owns a single random.Random seeded once; every provider draws from it. Determinism falls out of that choice instead of needing a separate mechanism.
  2. Schema validated up front. The whole schema is checked before the first record is generated, so a typo fails fast instead of halfway through a million-row run.
  3. Streaming output. Records are generated and written one at a time; generating a million rows never holds more than one record in memory. CSV columns come from the schema, so even CSV output streams.
  4. Zero dependencies. Everything is stdlib — no install friction, no supply-chain surface. The name/word pools are small curated lists kept in providers.py.

Output formats

Format Notes
jsonl (default) one JSON object per line — the usual choice for pipelines
json a single JSON array, written incrementally
csv nested objects flattened to dot-separated columns (address.city); lists joined with ;

Commands

fakerlite generate --schema S --count N [--seed S] [--format json|jsonl|csv] [--out FILE]
fakerlite validate --schema S
fakerlite types
fakerlite init [--out FILE]

Exit codes: 0 on success, 1 for a bad schema or unreadable file, 2 for bad command-line usage. --out - (the default) writes to stdout.

Running tests

pip install pytest
pytest

Tech stack

Python 3.9+ (stdlib only), pytest.

About

Seeded fake-data generator CLI: schema-driven synthetic datasets in JSON, JSONL and CSV

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages