API, Data & Developer Tools

JSON Schema Sample Generator

Generate valid sample documents and boundary edge cases from a JSON Schema, with a seed for reproducibility and limits on depth and size.

  • Valid samples
  • Edge cases
  • Self-validation result
Runs in your browser

Everything you paste, type or drop is processed in this browser tab. It is not uploaded, logged, stored or sent to analytics.

Schema samples workspace

1 Your JSON Schema

Example:

Draft-07 and 2020-12 keywords. Local references such as #/$defs/address are resolved; remote ones are not fetched.

Drop a .json, .yaml or .yml schema, or (up to 2 MB).

2 Settings

3 Samples

Paste a JSON Schema, or load an example, then choose Generate samples.

What the JSON Schema Sample Generator does

This tool generates sample JSON documents that conform to a JSON Schema, plus a set of boundary edge cases - some valid, some deliberately invalid - and re-validates every one of them against your schema before showing it. Give it a seed and it produces the same data every time.

Hand-written test data tends to cover the happy path and nothing else. The useful cases sit at the edges: the shortest allowed password, an age of exactly the minimum, a missing required field, a value just outside an enum. Building those from the schema itself means the tests change when the contract does.

How to use it

  1. Paste a JSON Schema (draft-07 or 2020-12, as JSON or YAML) or drop the file. Local references such as #/$defs/address are resolved.
  2. Set a seed, how many samples you want, how many items arrays should hold and whether optional properties are included.
  3. Leave the edge-case option ticked to build boundary cases alongside the samples.
  4. Choose Generate samples. Each sample shows whether it passed validation; the Edge cases tab shows what each case should be and what the validator actually says.
  5. Download the samples as a JSON array or JSON Lines, and the edge cases as JSON with their expected verdicts, ready for table-driven tests.

Reading the results

A sample marked valid passed validation against your schema, including referenced definitions, formats and patterns. The generator does not trust itself: if a sample fails, it is shown as failing with the reason.

Each edge case changes exactly one field of a valid sample, so a case labelled invalid tests one rule at a time. Behaving as labelled means the validator agreed with the label; a disagreement usually means two rules interact - for example, forcing one array item to a particular enum value can duplicate another item under uniqueItems. Candidate valid cases broken that way are dropped and counted in a note.

Generator notes list every approximation: a regular expression too complex to generate, a format it does not know, a recursive reference cut short, or constraints that leave no valid value at all.

Worked example: a sign-up request schema

Load the Sign-up form example: a 2020-12 schema with an email, a username pattern ^[a-z][a-z0-9_]{2,15}$, a 12 to 64 character password, an age from 16 to 120, an optional nullable referral code, a referenced UK or Irish address with a postcode pattern, and one to three unique interests.

With seed 7 and three samples, all three are valid. The first has username a5nflllcs, age 23, referral code REF-778118 and the postcode G6O 8CI, which matches the postcode pattern even though it is not a real postcode.

The edge-case builder produces 58 cases that behave as labelled - among them age 16 and 120 (valid), 15 and 121 (invalid), a fractional age (invalid), an 11-character password (invalid), a missing address.postcode (invalid), an extra property the schema forbids with additionalProperties: false (invalid), and a null referral code (valid). One candidate case was dropped because it would have duplicated an interest.

Which keywords are honoured

Types (including type arrays), const, enum, format (date-time, date, time, email, uuid, uri, uri-reference, hostname, ipv4, ipv6, duration, byte), pattern, minLength/maxLength, minimum/maximum and both exclusive forms, multipleOf, minItems/maxItems, uniqueItems, tuple prefixItems, required, properties, additionalProperties, minProperties/maxProperties, dependentRequired, allOf (merged), and oneOf/anyOf (one branch chosen by the seed).

not, if/then/else, contains and unevaluatedProperties are not targeted when generating. The validator still checks the ones it implements, so a sample that happens to break them is reported rather than passed.

Limitations: what the result does not prove

  • Valid is not the same as realistic. The data satisfies the schema but knows nothing about your domain - postcodes match the pattern without existing, and amounts are not related to each other.
  • Regular expressions with look-arounds, back-references or word boundaries cannot be generated; the field gets a placeholder that fails validation and a note says why.
  • Remote $ref targets are not fetched, and $id-based or anchor references are not resolved - bundle the schema into one document first.
  • Validation follows draft-07 semantics with the common 2020-12 additions. Rarely used keywords such as unevaluatedItems and $dynamicRef are not evaluated, so a document can pass here and fail a fully compliant 2020-12 validator.

Privacy: where your data goes

Everything you paste, type or drop is processed in this browser tab. It is not uploaded, logged, stored or sent to analytics. Session recording and tag-manager scripts are switched off on this page.

Standards and sources

Frequently asked questions

How is this different from a JSON Schema faker library?

The approach is the same - walk the schema and pick values - but every sample and edge case is re-validated here, and every compromise is written down. You also get deliberately invalid boundary cases, which a faker does not produce.

Why use a seed for test data?

A seed makes generated data reproducible. Tests that fail on a particular document can be re-run with exactly that document, and fixtures do not churn in code review. Change the seed when you want fresh values that are equally valid.

What does an invalid edge case look like?

A valid sample with one change that breaks exactly one rule: a number one below the minimum, a string one character over the maximum, a value outside the enum, a required property removed or an unexpected property added. Each is labelled with the field and the rule it targets.

Can it generate data from a schema that uses oneOf?

Yes. One alternative is chosen per sample using the seed, merged with any sibling keywords, and generated. Because oneOf requires exactly one match, the result is validated; if two alternatives overlap, the sample is flagged instead of passed.

Does it support YAML schemas?

Yes, through a deliberately small YAML reader that refuses anchors, aliases, merge keys and tags. Those features are not needed for JSON Schema and are behind well-known denial-of-service and deserialisation attacks.

What limits stop a huge schema freezing the page?

Arrays are capped at 20 items, nesting at 12 levels, and a sample at 6,000 generated values. Recursive references are followed once and then stopped. When a limit is hit, a note names the path.

Last reviewed by the A2Z.Tools team against the sources listed above.

Rate this tool

Was this tool useful? Your feedback helps us improve it.

No ratings yet — be the first to rate this tool.
Your rating (required)
0 / 2000

Please do not include passwords, payment details or other sensitive information.

Your feedback is sent privately to the A2Z.Tools team and will not be posted publicly.