Dev tools

JSON Schema generator

Infer a draft-07 JSON Schema from an example JSON document. Every observed key is marked required, arrays are typed from their first element. Runs on your device.

Runs on your device. The file is never uploaded.

JSON Schema generator reads one example document and prints a draft-07 schema for it, with $schema set to http://json-schema.org/draft-07/schema# at the top. Whole numbers are typed integer and the rest number, and an array takes its items schema from element zero. No enums, formats, minimums or descriptions appear, because one example cannot support them.

Input

Questions

Which JSON Schema draft does it emit?

Draft-07. The output starts with a $schema of http://json-schema.org/draft-07/schema# and then describes the shape of the document you gave it, pretty-printed with 2 spaces. It infers from one example, so treat the result as a first draft to edit rather than a finished contract.

Why is every field marked required?

Because the generator only sees one document, and every key present in it is listed in that object's required array. It has no way to know which fields are optional. Delete the entries you want to be optional after generating, or generate from an example that shows the minimum shape.

How are arrays typed?

From the first element only. An array of objects produces an items schema built from element zero, so a later element with extra keys is not reflected. An empty array gives an empty items schema, which matches anything. Mixed-type arrays are described by whatever their first entry happens to be.

Why is my number typed as integer?

Whole numbers get type integer and everything else gets type number. Since JSON does not distinguish 1 from 1.0, a value written 1.0 in your file is a whole number by the time it is inspected and is typed as integer. Change it by hand if the field can hold fractions.

Does it produce enums, formats or ranges?

No. The output is types, properties and required lists only. There are no enum values, no format keywords for dates or emails, no minimum and maximum, and no descriptions. Those are judgements about your data that one example cannot support.

Is the example document uploaded?

No. It is parsed and inspected in a Web Worker in this tab, which matters because example payloads usually come straight from a real API response. Nothing is sent to a server and nothing is stored. Drop several examples at once and you get one schema per file.

Related Dev tools