How to use it
- Paste a JSON document, an array of records or JSON Lines (one sample per line), or open a file.
- For an array of records, tick “A top-level array is a list of samples” to describe one record.
- Choose the options: a title, required keys, no other keys, formats, examples.
- Copy the schema or download it as a .schema.json file, then adjust it to your data.
Rules and limits
How the schema is made
- Samples: one JSON document, the items of a top-level array (with the option), or several documents, one per line (JSON Lines, recognised by itself). They are merged into one schema that starts with
"$schema": "https://json-schema.org/draft/2020-12/schema". - Types:
object,array,string,boolean,null; a number written with digits only isinteger, one with a decimal point or an exponent isnumber. A key seen with several types gets a list, for example["string", "null"]. propertieskeeps the keys in the order they first appear;requiredlists the keys that every object at that place has;itemsmerges all items of all arrays there and is left out when every array is empty.- A
format(date-time,date,email,uri,uuid) is added only when every string there matches it: dates and times as in RFC 3339;urionly with a scheme and//, ormailto:,urn:,tel:. - Options: a
title,"additionalProperties": falseon every object, andexampleswith up to 3 different values per field, written as in the samples.
Limits
- Tested in Chrome on a laptop: a 50 MB array of 393,188 records made into a schema in 8.5 s. Inputs over 50 MB are refused with a message.
- Data nested up to 1,000 levels.
- The schema describes what the samples show, nothing more: add value ranges, lengths, lists of allowed values and patterns by hand.
Questions and answers
Why is a field not in the required list?
Because one of your samples does not have it. Add the field to that sample if it is always there in reality, or edit the list by hand; the page can only go by what it sees.
Why does a field get “number” and not “integer”?
Because a sample writes it with a decimal point or an exponent, such as 2.0 or 1e3. A price written as 10.00 should stay a number; change it to integer by hand if the field only ever holds whole values.
Does a validator check the formats?
Only when you ask it to: in draft 2020-12 “format” is an annotation by default, and many validators check it only with format checking switched on. Because the page adds a format only when all your values match, switching it on will not reject your samples.
Can it describe records of different kinds?
It merges everything into one schema, so a field that is text in one sample and a number in another gets both types. For records of different kinds, make one schema per kind and join them with oneOf by hand.