Merged, not repeated
All the items of an array described once, with required keys the ones present in every item.
Infer a draft 2020-12 JSON Schema from sample JSON, with types, required keys, merged array items and formats only where every value matches.
Paste a JSON sample or open a .json file
Choose the options
Copy or download the schema
A JSON Schema says what a JSON document may contain, and validators, form builders, API tools and code generators all read one. Writing it by hand from an example is slow. Paste an example and this writes a draft 2020-12 schema that the example passes.
Types come from the values: string, boolean, null, object, array, and integer when every number at that place is whole, number when any has a fraction. Where values differ, the type is a list, such as [“string”, “null”].
An object’s properties are every key seen. With the required option on, the required list holds the keys present every time that object appears, so a key missing from one array item is optional. With “Refuse unknown keys” on, each object gets additionalProperties: false, which makes a validator reject keys the samples did not have.
Arrays get one items schema built from all their items together. An empty array gets no items schema, since nothing is known about what it holds.
Strings are tested against date-time and date (RFC 3339), time, email, UUID, IPv4 and URI patterns. A format is added only when every string at that place passes the same one. Draft 2020-12 treats format as an annotation unless a validator is told to assert it, and where one is, a wrong format turns into rejected records.
No minimum, maximum, length, pattern or enum is inferred. Three samples with the status “open” do not prove that “closed” is impossible, and a schema that said so would reject the next real record. Add those by hand where you know them.
To check a document’s syntax first, use the JSON formatter; for TypeScript types from the same sample, JSON to TypeScript.
Nothing is uploaded. Your data is read in this tab.
All the items of an array described once, with required keys the ones present in every item.
Email, date-time, date, time, UUID, IPv4 and URI, added only when no value disagrees.
Your data is read in your browser and never sent anywhere.
Nothing uploaded: open the Network panel while it runs and check.
No daily limits or watermarks: free batches take up to 20 images.
Works offline: once the page has loaded, on any current browser.
Every item is merged into one items schema. A key is listed if any item has it and marked required only if every item has it, and a field that is a number in one item and null in another gets both types.
Only when every string seen at that place matches it. One value that is not a date, or an empty string, leaves the format off, because a format that real data breaks makes a validator that asserts formats reject it.
When the file is a list of records, such as an API's response rows, ticking it describes one record from all of them, rather than describing the list. Leave it off to describe the array itself.
It describes the samples it was given, which is a starting point. Values the samples never showed, such as an optional key or a third type, are missing, and nothing about lengths, ranges or allowed values is guessed. Review it before using it to reject data.