JSON Schema Fake Data Generator
Operator: Abdulla Al Fahad. How tools are built and checked
A test database needs a few thousand rows that all obey one contract: plan is one of three values, orderRef looks like ORD-AB1234, seats stay between 1 and 25. Paste the JSON Schema that states those rules and this page writes the rows, up to 20,000 of them, as JSON, JSON Lines, CSV or SQL INSERT statements. The randomness is seeded: the seed fixture-1 gives the same 25 records on every run, so a fixture can be recreated from the schema plus one word instead of being committed as a file. Change one letter in the seed and every value changes.
Key features
- Honours type, enum, const, minimum, maximum, exclusive bounds, multipleOf, minLength, maxLength, minItems, maxItems and uniqueItems
- Writes strings for the formats email, date, date-time, time, uuid, uri, hostname, ipv4 and ipv6
- Builds a value for a regex pattern from a subset of the syntax, then tests it against the real RegExp
- Follows local $ref, merges allOf and picks one branch of oneOf or anyOf
- Exports JSON, JSON Lines, CSV with dotted columns for nested objects, and INSERT statements quoted for PostgreSQL, MySQL, SQLite or standard SQL
Which schema keywords shape the generated values
When a string has no format, enum or pattern, its property name decides the content: firstName, lastName, name, email, phone, city, country, state, zip, street, company, jobTitle, url, description and title draw from bundled lists (60 first names, 60 surnames, 40 cities, 30 countries and shorter lists for the rest). An integer property called id, rowId, index, no or number placed directly on the record counts up from 1 instead of being random. Dates fall between 2015 and 2025, so the output never depends on today's date.
Optional properties appear in 80% of records by default, and the selector also offers 100%, 50% or required only. Numbers with no bounds fall between 0 and 1000 and decimals are rounded to two places; an array with no limits holds 1 to 4 items; nesting stops at 8 levels. Keywords that are not applied (not, if, then, else, patternProperties, contains, prefixItems, propertyNames and a few others) are named in a warning instead of being ignored in silence.
How it works
The seed string is hashed with xmur3 into the state of a mulberry32 generator, so every random choice comes from one repeatable stream. Records are drawn in order from that stream, which means asking for 100 records and then 200 with the same seed leaves the first 100 unchanged.
A pattern is parsed into a small tree of sets, groups, alternatives and repeats, rendered at random, and tested with the real RegExp; after 12 failed attempts a warning says the pattern was not matched. Open-ended repeats (* and +) stop at 6 repetitions, so [a-z]+@x\.io gives short names. Back-references, look-arounds and \p{...} escapes fall outside the subset, produce a warning and fall back to a plain word.
Typical uses
- A QA engineer needs 5,000 users to load-test a signup report. The schema fixes plan to three values and seats to 1 to 25, the seed is release-42, and the CI runner regenerates the same file every night instead of storing it in the repository.
- A front-end developer mocks an API before the backend exists: 12 records with a nested address object and a tags array limited to three unique items, produced from the response schema the team agreed on.
Building one
- Paste a schema or drop a .json file onto the page.
- Set how many records you want, a seed and how often optional properties appear.
- Press Generate records and read any warnings above the output.
- Choose JSON, JSONL, CSV or SQL INSERT, set the table name and quoting for SQL, then download or copy.
Example
Schema with id, email, plan and orderRef, seed demo, 3 records, PostgreSQL
{ "type": "object", "required": ["id", "email", "plan", "orderRef"],
"properties": { "id": { "type": "integer" }, "email": { "type": "string", "format": "email" },
"plan": { "enum": ["free", "pro", "team"] },
"orderRef": { "type": "string", "pattern": "^ORD-[A-Z]{2}[0-9]{4}$" } } }SQL INSERT output
INSERT INTO "orders" ("id", "email", "plan", "orderRef") VALUES
(1, 'ravi.reyes@example.net', 'free', 'ORD-UB6420'),
(2, 'leila.murphy@mail.test', 'team', 'ORD-ON7597'),
(3, 'pavel.kaplan@example.com', 'team', 'ORD-TP0600');Things to check before you rely on it
Each keyword is satisfied on its own, and the page does not solve conflicting rules or re-validate the result against the whole schema. A string built from a pattern or a format is never cut or padded, because that would break the pattern. If 40 draws cannot meet minLength or maxLength as well, the pattern-valid value is kept and a warning says the length limit was not met.
The whole run may create 4,000,000 values (every object, array and scalar counts). A recursive $ref or nested minItems multiplies quickly, and ten self-referencing properties pass the limit on the first record. The page then stops with a message, or keeps the records finished so far and warns that fewer than the requested number were made.
Names, emails and addresses come from short bundled lists, so large runs repeat them. Email local parts get a number only about 30% of the time, duplicates across records are possible, and uniqueItems applies inside a single array, not across records.
CSV and SQL flatten an array to JSON text in one cell, and an empty nested object becomes the text {}. For child tables, export JSON and split it yourself.
- To get a mix of present and missing values for a nullable field, give it a type array such as ["string", "null"]; about one value in ten comes out null.
- Check the first 12 rows in the table under the output before exporting. They show every column the CSV and INSERT forms will contain, including dotted names such as address.city.
Common errors and how to fix them
- "The schema is not valid JSON: Unexpected token ..."
- The message comes from the browser's JSON parser and names the first bad character. Trailing commas and comments are the usual cause; a schema kept as YAML or JSON5 has to be converted to plain JSON first.
- A warning that a reference points outside this schema
- Only #/ references are followed. A https:// or relative-file $ref target is replaced by a plain word, so copy the definition into $defs and point to it with #/$defs/name.
Best practices
- Commit the schema and the seed together and quote both in the test that loads the data, so a changed schema is the only reason a fixture changes.
How CSV and SQL output are written
CSV columns are the union of every flattened key in order of first appearance, so an optional property missing from the first records still gets a column; an absent value is empty in CSV and NULL in SQL. Rows are grouped into INSERT statements of 100 rows each.
Identifiers are quoted with double quotes, or backticks for MySQL, and a quote character inside a name is doubled. String literals double their single quotes, MySQL mode also doubles backslashes, NUL characters are dropped and booleans are written TRUE or FALSE. In the CSV, a text value that starts with = + - or @ is written with a leading apostrophe, while numbers are written as they are.
Frequently asked questions
Can I generate related tables, such as customers and orders with matching ids?
Not in one run, because each run reads one schema. A workable route is to generate customers, whose id counts up from 1, then generate orders with an integer customerId bounded by minimum 1 and a maximum equal to the customer count; the keys then line up without a join.
How is this different from Mock CSV here?
Mock CSV builds up to 5,000 rows from a column list you define on that page and writes CSV only. This page reads a JSON Schema you may already have for validation, so the same constraints shape the data, and it also writes JSON, JSON Lines and SQL.