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.
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:
const— the only value the schema allows.default— the documented fallback value.examples[0], or OpenAPI 3.0's singularexample.enum[0]— the first accepted choice.- A value generated from
typeandformat.
So a schema that already documents itself with default/examples gets your
values back, not invented ones.
Supported schema keywords
- Types:
object,array,string,integer,number,boolean,null, union types such as["string", "null"](the first non-null member wins), and the boolean schemastrue/false. - Objects:
properties,required,additionalPropertiesas a schema. - Arrays:
items,prefixItems, draft-07 tupleitems: [...]withadditionalItems,minItems,maxItems,uniqueItems. - Strings:
minLength,maxLength, andformat—email,uuid,date,date-time,time,duration,uri,uri-reference,uri-template,hostname,ipv4,ipv6,byte,json-pointer,regex. Unknown formats fall back to a plain string, becauseformatis an annotation unless a validator opts in. - Numbers:
minimum,maximum,exclusiveMinimum,exclusiveMaximum(both the draft-04 boolean form and the numeric form),multipleOf. - Composition:
allOfis deep-merged;oneOf/anyOfuse the first branch. - References: local
$refpointers into the same document —#/$defs/Name,#/definitions/Name, or any JSON pointer such as#/properties/user. Recursive schemas stop at the first repeat withnull.
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
- The schema must be at most 1 MB, and generation stops after 50,000 values — lower Array items or untick Include optional properties if you hit that on a very wide schema.
- Array items accepts 0–50. A larger
minItemsalways wins, andmaxItemsstill caps the result, so bounded arrays stay valid. - Length assertions beat
format: withminLength/maxLengthset, the string is padded or truncated even if that spoils an email or UUID shape, because length is an assertion whileformatis an annotation. - Recursive
$refchains are cut at the first repeat and nesting stops after 32 levels; both emitnullat the cut point rather than looping forever. - Remote
$refs (https://…/schema.json#/…) are rejected with a clear error — there is no network fetch in a browser-local tool. Inline your definitions under$defsfirst. - Not synthesised, and reported rather than faked where it matters:
pattern,patternProperties,not,if/then/else,dependentSchemas,dependencies,propertyNames,contains,minProperties/maxProperties, andreadOnly/writeOnlyfiltering. A schema whose validity rests only onpatternmay need a manual touch-up. - A schema of
falseaccepts no instance at all, so it returns an error instead of a sample.
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=trueMachine-readable descriptor: tool.json — title + parameters JSON Schema for agents.
