JSON Formatter & Validator
Format, validate and minify JSON with syntax highlighting and error detection.
Paste any JSON object or array and get a JSON Schema (Draft 2020-12) describing its structure. The generator infers types, marks every present field as required, handles nested objects and arrays of objects by merging properties across items, and produces a schema you can hand-edit further or wire straight into a validator like Ajv, jsonschema, or any IDE that supports schema-driven autocompletion. Everything runs in your browser.
JSON Schema is a JSON-based vocabulary for declaring what JSON data should look like. A schema document specifies which keys are required, what types each key's value must be, what values are allowed, and how nested objects and arrays are structured. Every major language has at least one mature validator that accepts the same schema, which makes JSON Schema the closest thing to a universal validation contract in the JSON world.
The two common ways to get a schema: write one by hand against the spec, or infer one from a real sample of data. Hand-writing is precise but slow and easy to get wrong on edge cases. Inferring from a sample is fast and gets you 90% of the way there — the inferred schema captures every type, required field, and nested structure the sample shows. The remaining 10% is hand-editing: adding format constraints (email, date-time, uuid), value ranges (minimum, maximum), enum lists, regex patterns, and conditional rules that the sample alone can't reveal.
JSON Schema's biggest practical wins are in API design (clients and servers agree on the shape of every request and response), config validation (catch typos in YAML/JSON config files at startup, not at runtime), and IDE support (live autocompletion as you type a config or fixture). It's worth writing the schema even when validation isn't strictly required — the schema document itself becomes lightweight, language-independent documentation.
$schema declaration so any validator can identify which draft to apply. The schema is forward-compatible with Draft 2019-09 in most cases — the differences mostly affect dynamic references and conditional schemas, neither of which the inferrer emits. Older drafts (Draft 7, Draft 6, Draft 4) require minor adjustments: change the $schema URL, replace $defs with definitions, and remove prefixItems if you used it.oneOf. So an array like [{"a": 1}, {"a": "x", "b": true}] produces a schema with properties a (oneOf integer or string, required) and b (boolean, optional). For strict per-item shapes, hand-edit the generated schema or use a tuple validation with prefixItems."format": "email", "format": "date-time", "format": "uuid", or any other standard format keyword. Most JSON Schema validators treat formats as advisory by default; pass strict-format options to enforce them at validation time.ajv.compile(schema)(data) — it returns a boolean and populates compile.errors with details. In Python, install jsonschema and call jsonschema.validate(data, schema). Most modern IDEs (VS Code, JetBrains) accept a $schema URL or path inline and provide live autocompletion and validation as you type. The tool's output is a complete, standalone schema you can save to a file and reference.