JSON to JSON Schema
Give a representative JSON value and get back a JSON Schema that describes it. Objects produce properties plus a required list, arrays merge the schema of every element, and primitives map to their type. Everything runs in your browser.
🔒 100% Client-Side & Private — processed locally in your browser. Files never leave your device.
Options
Your result will appear here
Type or paste your input above, adjust the options, then press Run. Tip: press Ctrl+Enter to run, and ? for every shortcut.
How it works
From a sample value to a schema
Paste any JSON value — an object, an array or even a bare string — and the tool walks it to build a JSON Schema draft 2020-12 document, always stamped with the draft meta-schema URI and written as schema.json. Objects produce a properties map with a schema per key, arrays produce an items schema derived from their elements, strings, booleans, nulls map to their own types, and numbers are split into integer when they have no fractional part and number otherwise. A bare array or primitive at the root is handled just as well as an object.
The two switches that change the shape
Listing every object key as required is on by default, which records the sample’s keys in the required array so a validator would reject a document missing any of them; turn it off when the sample just happened to include optional fields. The additional properties switch controls the additionalProperties keyword that is written on every object: off writes false, tightening the schema to exactly the keys seen, on writes true so extra members are permitted.
How arrays of differing elements are merged
An array is rarely uniform, so element schemas are merged rather than taken from the first one. Object elements have their properties unioned, and a key is only listed as required if it appears in every element. When types disagree, integer and number collapse to number, distinct primitive types become a sorted type array such as ["integer", "string"], and shapes that cannot be reconciled are wrapped in anyOf. An empty array gets no items keyword at all.
What it cannot infer and where it runs
A schema can only describe what the sample shows, so strings carry no format, length, pattern or enum, numbers carry no minimum or maximum, and there is no $defs reuse or title on nested objects — the title option applies to the root schema only. Because all of this is a single pass over text you paste, the JSON never leaves the browser; the conversion and the pretty-printed output are produced locally in the tab.
Questions
Which draft does it target?
Draft 2020-12. The output always sets "$schema" to the draft 2020-12 meta-schema URI.
How are arrays with different element shapes handled?
Element schemas are merged: object properties are unioned (a key present in every element stays required), and differing primitive types collapse to a "type" array such as ["integer", "string"].
Are integers distinguished from floats?
Yes. A whole number infers "integer"; a number with a fractional part infers "number".
Related tools
See categoryJSON to TypeScript
Generate TypeScript interfaces or type aliases from a JSON sample, with nested named types.
JSON Formatter & Validator
Pretty-print, minify, recursively sort keys or validate JSON, with line/column errors.
JSON to YAML
Convert JSON to YAML on your device, with a 2- or 4-space indent.
NDJSON <-> JSON Array
Convert newline-delimited JSON to a JSON array and back, one compact value per line.