About JSON to JSON Schema
Writing a schema by hand for a large API response is slow. Paste an example document and get a draft 2020-12 schema that describes it: the type of every value, the properties of every object and the shape of array items.
Arrays of objects are merged, so a key that appears in some items but not others is still listed, and only keys found in every item are marked required. Strings that all look like dates, emails or URLs get a format. Nothing leaves your browser.
How to use it
- Paste a representative JSON document into the Input box.
- Keep “Mark properties as required” on to list keys that are always present, or switch it off for a looser schema.
- Copy the generated schema from the right and adjust it, for example by adding descriptions or enums.
Frequently asked questions
How are null values handled?
A property that is null in one sample and a string in another gets the type ["string", "null"]. If it is only ever null, its type is "null", so give it a real value in your sample if you can.
How does it tell integers from numbers?
Whole numbers become "integer". If the same property has both whole and decimal values across samples, it becomes "number", which covers both.
Can I use the result as-is?
It is a starting point. A schema inferred from one example only knows what that example shows, so review required keys, add constraints such as minimum or pattern, and test it with a validator.