Build a draft 2020-12 schema from sample JSON
null are supported, at any nesting depth. Arrays are inspected element by element and differing types are combined with anyOf.
Paste sample JSON on the left and press "Generate schema" to get a JSON Schema (draft 2020-12) on the right. This is useful for drafting a schema from an example API response, for starting validation of a config file, or for having a machine state the shape of your test data. Paste an array and the result is one schema derived from every element.
With "Mark every key required" on, every key seen in the sample becomes required. Starting strict and removing the optional keys afterwards is usually faster than the other way round. Turn it off for data with many optional fields. "Infer string format" looks only for date, date-time, email and uri. Strings that match none of them get no format, because guessing would add a constraint the data does not support.
Shapes that never appear in the sample are unknown to it. Minimum and maximum values, enum, pattern and string length cannot be decided from one sample either, so they are not emitted. Treat the output as a draft, not as the specification itself.
It is valid and ready to run, but it only encodes the facts present in your sample. A schema describes the shape that fits this data, not the contract of your API, so review it before using it. Pay particular attention to required and to any field where the sample showed only one kind of value, and check them against the real range of your data.
That is fine. Every element is inspected, not just the first one, and differing types are combined with anyOf. Objects are merged property by property, and required keeps only the keys that were present in every element. Integers mixed with decimals are combined as number.
No. Generation runs entirely in JavaScript in your browser. The JSON you paste is never sent to or stored on a server.