About JSON Schema Generator
Writing a schema by hand for an API response or a config file is slow and easy to get wrong. Paste a real example and get a draft 2020-12 schema back: every property with its type, nested objects and arrays described all the way down, and the keys that appeared every time marked as required.
The more examples you give it, the better the guess. Items of an array are merged, so a key missing from one item becomes optional and a value that is sometimes null gets both types. Treat the result as a solid first draft to tighten by hand.
How it works
- Each value becomes a type: object, array, string, integer, number, boolean or null. A field that holds both whole and decimal numbers becomes number.
- All items of an array are merged into one items schema. A property is required only when it appears in every object merged at that place; its value may still be null.
- When a field holds different kinds of value, the schema lists them together, such as ["string", "null"]. Keywords like properties or format apply only to their own type, so the combined schema stays correct.
- A string field gets a format (date-time, date, time, uuid, ipv4, email or uri) only when every value seen there matches it.
Questions
Which version of JSON Schema does it produce?
Draft 2020-12, the current one, declared with $schema at the top. The keywords used (type, properties, required, items, format, additionalProperties) mean the same in drafts 6 and 7, so only the $schema line would need changing for an older validator.
Why is a field I always send not required?
Only the sample is visible to this tool. If one of the objects you pasted lacks the key, it cannot be required. Add it to the sample, or edit the required list afterwards.
Does it work out enums, minimums or patterns?
No. A sample cannot show which values are allowed, only which were present, so the schema describes structure and types. Add enum, minimum, maxLength and similar rules yourself where they matter.
How large a sample can I use?
Up to 5 MB of JSON nested at most 256 levels deep. Large arrays are fine: fifty thousand records are merged in well under a second.
Everything you enter here is processed in this browser tab. Nothing is uploaded, logged or shared. How privacy works here.