Writing a JSON Schema by hand from a large API response is tedious and easy to get subtly wrong. This page does the mechanical part: it reads a sample document and writes the structure and types it observes, leaving you to add the judgement a sample cannot supply.
What a sample can and cannot prove
This distinction is the whole story of using a generated schema well:
| A sample proves | A sample cannot prove |
|---|---|
| These keys exist | Whether other keys are allowed |
| This value is a string | Whether it must match a pattern or format |
| This value is 42 | Whether the range is 1–100 or unbounded |
| This key is present | Whether it is required or merely present here |
| This array holds objects | Whether it may be empty, or has a length limit |
The generator is deliberate about staying on the left-hand column. Everything on the right is left for you to add, because inventing a constraint is how a generated schema starts rejecting valid documents three months later.
Integer versus number
The type is decided by how a number is written, not by what it equals:
42becomesinteger42.0becomesnumber4.2e1becomesnumber123456789012345678901234567890becomesinteger
That last one is the case that separates this from most generators. Because numbers keep their source text rather than being parsed into a double first, a 30-digit identifier is still recognised as an integer instead of being demoted the moment it stops fitting.
Arrays with mixed items
Every element is described, then the descriptions are merged into one items schema:
- Objects union their properties. A key that appears in some elements and not others still gets a property entry, so nothing is lost.
- Required keeps only the keys present in every element. One absence is proof the key is optional, and that is the strongest inference a sample supports.
- Plain values of differing types widen into a union, so
[1, "two"]produces{"type": ["integer", "string"]}rather than a guess from the first element. - An empty array gets no
itemsat all.
Required, and when to turn it off
The switch decides whether every key present in the sample is listed as required:
- On when the sample is the contract — a config file, a fixture, a request body you control.
- Off when the sample is one response among many. A key you happened not to receive this time would otherwise become mandatory forever.
Inside arrays the tool applies the stricter rule automatically, regardless of the switch: a key missing from any single element is never required for that item.
Then validate against it
A generated schema earns its keep once you have edited it — added the formats, tightened the ranges, decided what is genuinely optional. The validator on the sibling page checks a document against it and reports every rule that fails, also entirely in your browser.