Generate a sample JSON instance from a JSON Schema

Paste a JSON Schema and get the smallest JSON document that satisfies it — required fields, defaults, enums and $refs resolved. Deterministic and fully browser-local.

Try:
Sample JSON

About this tool

This tool turns a JSON Schema into the smallest JSON document that satisfies it. Paste a schema, and you get an example instance you can drop straight into API documentation, a test fixture, a mock response, or a request body you are about to send by hand.

It is deliberately minimal, not random: by default only required properties appear (plus any property that declares a default), every value is derived from the schema itself, and the same schema always produces the same output. Nothing is uploaded — the schema is parsed and the sample built inside your browser.

Tick Include optional properties when you want the full shape instead, raise Array items to show more than one entry per array, and untick Pretty-print for a single compact line.

Where each value comes from

Values are taken from the first of these the schema provides, in order:

  1. const — the only value the schema allows.
  2. default — the documented fallback value.
  3. examples[0], or OpenAPI 3.0's singular example.
  4. enum[0] — the first accepted choice.
  5. A value generated from type and format.

So a schema that already documents itself with default/examples gets your values back, not invented ones.

Supported schema keywords

Drafts 07, 2019-09 and 2020-12 all work; the tool reads the keywords that are present rather than requiring a $schema declaration.

Worked example

Schema:

{
  "type": "object",
  "properties": {
    "id": { "type": "integer", "minimum": 1 },
    "email": { "type": "string", "format": "email" },
    "nickname": { "type": "string" }
  },
  "required": ["id", "email"]
}

Sample JSON (defaults: optional properties off, one array item, pretty-printed):

{
  "id": 1,
  "email": "[email protected]"
}

nickname is optional, so it is left out. id becomes 1 because minimum: 1 is the smallest allowed integer, and email is shaped by its format.

Tick Include optional properties and nickname joins the sample as "string".

Limits & edge cases

FAQ

Will the generated sample actually validate against my schema?

For the keyword subset listed above, yes — required properties are present, enums and const are respected, and numeric, length and item bounds are honored. The exceptions are the keywords listed under limits, chiefly pattern: a plain string cannot be synthesised to match an arbitrary regular expression, so run the result through a validator if your schema leans on pattern or conditional subschemas.

How is this different from a fake-data generator?

A faker invents plausible-looking rows and usually varies them per run. This tool produces one minimal and deterministic instance: the same schema and options always return byte-identical JSON, and values come from the schema's own const, default, examples and enum before anything is generated. That is what you want for documentation snippets, golden files and fixtures that must not churn in version control.

Why are optional properties missing from my sample?

By design — a minimal instance only needs the properties listed in required. Tick Include optional properties to emit every property in properties. One exception applies either way: a property that declares a default is always included, since the default is part of the effective document.

Does it follow $ref, allOf and oneOf?

Local $ref pointers are resolved against the same document, including #/$defs/Name, #/definitions/Name and ordinary JSON pointers, and keywords sitting next to a $ref are merged over the target. allOf branches are deep-merged into one effective schema; oneOf and anyOf use the first branch, which is the conventional choice for documentation examples. Remote $refs are not fetched.

How many items does an array get?

The Array items control, which defaults to 1. minItems raises it when it is larger, maxItems lowers it, tuple positions from prefixItems are always all emitted, and uniqueItems makes repeated entries distinct so the array stays valid.

Developer & Automation Access

Run it from the terminal

Same engine as this page, headless — via the gizza CLI:

gizza tool json-schema-to-sample '{
  "type": "object",
  "properties": {
    "id": { "type": "integer", "minimum": 1 },
    "email": { "type": "string", "format": "email" },
    "role": { "enum": ["admin", "user"] }
  },
  "required": ["id", "email"]
}'

New to the CLI? Get gizza →

Open it by URL

Pre-fill and auto-run this tool with query parameters — the names match the API/CLI:

https://gizza.ai/tools/json-schema-to-sample/?schema=%7B%0A%20%20%22type%22%3A%20%22object%22%2C%0A%20%20%22properties%22%3A%20%7B%0A%20%20%20%20%22id%22%3A%20%7B%20%22type%22%3A%20%22integer%22%2C%20%22minimum%22%3A%201%20%7D%2C%0A%20%20%20%20%22email%22%3A%20%7B%20%22type%22%3A%20%22string%22%2C%20%22format%22%3A%20%22email%22%20%7D%2C%0A%20%20%20%20%22role%22%3A%20%7B%20%22enum%22%3A%20%5B%22admin%22%2C%20%22user%22%5D%20%7D%0A%20%20%7D%2C%0A%20%20%22required%22%3A%20%5B%22id%22%2C%20%22email%22%5D%0A%7D&include_optional=true&array_items=1&pretty=true

Machine-readable descriptor: tool.json — title + parameters JSON Schema for agents.