datagen is a schema-driven CLI that populates Postgres and MongoDB with realistic seed data using Faker.js — fast, reproducible, and built for developers who hate writing seed scripts.
// Built for developers
Declarative schemas, real Faker.js methods, and database-native inserts — without leaving the terminal.
PostgreSQL and MongoDB drivers built in. Auto-detected from your connection string.
Define foreign keys in YAML. datagen builds a dependency graph and populates in the right order.
Schemas live in .datagen/ as YAML. Commit them with your code.
Pass --seed 42 for byte-identical output. Perfect for CI and demos.
No schema file needed for quick seeding. Pass fields directly on the command line.
Schema errors, FK violations, and unknown Faker methods are caught before insertion.
// 01 — Install
datagen ships as a global npm package. Install it once and run datagen from any project. Your connection lives in ~/.datagen/config.json; schemas live alongside your code.
$ npm install -g @jircik/datagen
$ pnpm add -g @jircik/datagen
$ yarn global add @jircik/datagen
$ datagen --version 1.0.0
// 02 — How it works
Connect once, write a schema (or skip it), populate. That's it.
datagen detects the database type from your connection string and saves it globally.
Drop a YAML schema in .datagen/ mapping fields to Faker methods.
Run one schema, a whole folder, or pass fields inline. datagen handles the rest.
// 03 — Commands
Eight commands. Each does one thing well.
datagen connect <uri>
setup
Save and validate a database connection. Auto-detects Postgres or MongoDB.
datagen status
setup
Show the currently connected database with masked credentials.
datagen disconnect
setup
Clear the active connection from the global config.
datagen populate ...
core
Insert fake data from a schema file, an entire .datagen/ folder, or inline fields.
datagen schema validate
schema
Validate types, relations, and primary keys in a schema file before running.
datagen schema list
schema
List all .schema.yaml files in the current project.
datagen list tables
inspect
List all tables (Postgres) or collections (MongoDB) in the connected database.
--dry-run / --seed
flags
Preview without inserting, or fix the seed for byte-identical output.
// 04 — Schema examples
Plain YAML. Versioned next to your code. No DSL to learn — just Faker.js method names.
target: postgres table: posts fields: id: type: string.uuid primary: true title: lorem.sentence body: lorem.paragraphs user_id: type: relation table: users field: id strategy: random
target: mongo collection: orders fields: status: type: helpers.arrayElement values: ['pending', 'paid', 'shipped'] amount: type: number.float min: 10 max: 9999 tags: type: array items: commerce.productAdjective length: 3
$ datagen populate --table users \ --field "name:person.fullName" \ --field "email:internet.email" \ --field "age:number.int:min=18:max=80" \ --count 50
Skip the manual schema authoring. The official Claude Code plugin teaches Claude how to set up connections, generate schemas from your tables, and run populate commands — all from a natural-language prompt inside your editor.
.datagen schemas from your existing tablesSeed the users and posts tables with 200 realistic rows each.
I'll generate schemas from your tables and populate them in the right order.
Done — 400 rows seeded in 380ms.
// 05 — FAQ
No. datagen only inserts data. Your tables and collections must exist already — bring your own migrations.
For every type: relation field, datagen runs a SELECT to fetch existing IDs and picks them using your strategy (random or sequential). In folder mode, dependencies are sorted automatically.
Yes — that's the point. Schemas live in .datagen/ in your repo. Connection strings live globally in ~/.datagen/config.json and never touch your project files.
One-to-many and many-to-one are supported today. Many-to-many (join tables) and self-referencing relations are on the post-MVP roadmap.
datagen is built for local and staging environments. Don't point it at production — it inserts data, and that data is fake.
Install datagen and you'll never write another seed script again.
npm install -g @jircik/datagen