Need a schema for your API or validator? JSON to JSON Schema in one click — paste a sample, hit Generate and download a Draft 2020-12 schema. Runs in your browser, nothing uploaded.
or
Writing a JSON Schema by hand for a non-trivial payload is tedious and error-prone — every property, every nested object, every array shape has to be described correctly before any validator will trust it. A JSON to JSON Schema generator turns a representative sample into a working Draft 2020-12 schema in one step: types are inferred, required fields are listed, and the result is a clean starting point you can tighten or relax to match the real contract.
JSON Pretty produces a strict schema by default — every observed property is required and additional keys are disallowed — so you can dial permissiveness in rather than out. Need to inspect or reshape the source before generating? Open it in our JSON editor for a tree view with search and copy-by-path. New to JSON? Our beginner's guide to JSON walks through the structure with examples.
A sample document and the schema it produces:
{
"id": 1,
"user": "alice",
"active": true,
"tags": ["admin", "editor"]
}{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"id": { "type": "integer" },
"user": { "type": "string" },
"active": { "type": "boolean" },
"tags": {
"type": "array",
"items": { "type": "string" }
}
},
"required": ["id", "user", "active", "tags"],
"additionalProperties": false
}Generate a JSON Schema from JSON in three simple steps — no account needed
Paste a representative JSON document, or click "Upload file" to load a .json file from your device.
Press Generate. The tool walks the data tree, infers types, and emits a Draft 2020-12 JSON Schema with required properties listed.
Copy the schema to the clipboard, or download a .json file ready for Ajv, jsonschema or OpenAPI tooling.
Why bother with a schema at all? A few things you can do once the shape is described.
Format any JSON response and explore it in a clean tree view — right where you open it, no copy-paste.
Full editor with tree view, search and copy-by-path for working with the source JSON before generating.
Convert a JSON array of objects into CSV ready for Excel, Numbers or Google Sheets.
Convert JSON into clean YAML ready for Kubernetes, Docker Compose or CI configs.
Convert JSON into a well-formed XML 1.0 document with attributes preserved.
Turn CSV rows into a JSON array of objects with inferred types.
Parse YAML configs into clean indented JSON ready for APIs and code.
It inspects a sample JSON document and produces a JSON Schema that describes its shape — what fields exist, what types they hold, which are required and how arrays are structured. The schema can then be used to validate other JSON payloads or to drive code and documentation generators.
JSON Schema is a JSON-based vocabulary for describing the shape of JSON data. Tools like Ajv (JavaScript), jsonschema (Python) and OpenAPI use it to validate API requests and responses, generate typed clients, document endpoints and power form-driven UIs.
Draft 2020-12, the current official version. The "$schema" property at the top of the output points at "https://json-schema.org/draft/2020-12/schema" so every modern validator recognises it automatically. The vocabulary is backwards-compatible with most Draft 7 tooling.
Every key that appears in the sample is marked required by default — the schema treats your sample as the canonical shape. If some fields are actually optional, remove them from the "required" array in the generated output before using the schema for validation.
The first element of each array sets the inferred item type. If your sample mixes types within a single array, edit the generated schema to use the "items" keyword with "anyOf" or "oneOf" so validation accepts every variant.
Yes. Values that look like email addresses, dates or date-times are tagged with the corresponding "format" so validators can enforce the pattern. Other strings are emitted without a format and accept any text.
Yes — every generated object has "additionalProperties: false", so validation will reject keys that were not present in your sample. If you want a more permissive schema, remove that line from the output, or replace it with a property schema for the allowed extras.
Yes. The generator runs entirely in your browser using JavaScript. Nothing is sent to a server, nothing is stored.
Save it as a .json file alongside your code, then load it with a validator. Ajv, for example, accepts it directly: const validate = ajv.compile(schema); validate(payload). For OpenAPI specs, drop the schema under "components/schemas" and reference it by $ref.
Absolutely — the output is plain JSON Schema text. Add descriptions, tighten formats, loosen required fields, attach examples, or merge it with $ref-d sub-schemas. The generator gives you a sensible starting point, not a finished spec.
The generator only knows about what it sees. If a field appears in real data but not in your sample, the resulting schema will reject it. Use a sample that covers every property you care about — or add the missing fields to the schema by hand after generating.