Dev · 108 tools · nothing uploads

JSON Schema generator

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

Input

live

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.

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

n→nJSON format / validateParse, validate and pretty-print JSON, with a clear parse-error message if it is broken.Runs on each file you dropn→nJSON sort / minify / escapeSort object keys, minify to one line, or escape/unescape JSON for embedding inside another string.Runs on each file you dropn→nJSONPath queryQuery JSON with a JSONPath expression: dot/bracket access, wildcards (*), recursive descent (..). No filter expressions (?()) or slices; those need a full JSONPath engine this build does not have.Runs on each file you dropn→nJSON to TypeScriptJSON to TypeScript. Infers types from an example JSON document. Nested objects become named types by their key; mixed-type arrays fall back to a broad/any type.Runs on each file you dropn→nJSON to GoJSON to Go. Infers types from an example JSON document. Nested objects become named types by their key; mixed-type arrays fall back to a broad/any type.Runs on each file you dropn→nJSON to RustJSON to Rust. Infers types from an example JSON document. Nested objects become named types by their key; mixed-type arrays fall back to a broad/any type.Runs on each file you dropn→nJSON ↔ CSVConvert a flat JSON array of objects to CSV and back. CSV has no type system: JSON->CSV renders numbers/booleans/null as text and CSV->JSON always comes back as strings. A nested object or array field is refused by name rather than silently flattened. CSV parsing is fully quote-aware, embedded newlines included; a file with an unterminated quote is refused rather than guessed at.Runs on each file you dropn→n.env ↔ JSONConvert a .env file to a flat JSON object and back. Values are treated as strings both ways. No nesting, no type coercion of numbers/booleans on the JSON->env direction beyond JSON.stringify.Runs on each file you drop