JSON to JSON Schema
Turn an example payload into a JSON Schema you can refine and use to validate future documents.
Your data stays on your device
Input — JSON
- characters
- 0
- lines
- 0
- size
- 0 B
Output — JSON Schema
- characters
- 0
- lines
- 0
- size
- 0 B
Options
About this tool
A JSON Schema describes the shape data must take: which types are allowed, which properties exist and which are required. Writing one by hand is tedious, so this tool infers a solid first draft from an example document.
Every object contributes its keys as properties and as required entries; arrays are described by the union of their elements, so a mixed array still gets a schema that accepts all of it. Integers and decimals are distinguished. The output targets Draft 2020-12 by default.
Inference has a built-in limit worth understanding: a schema can only describe what the example demonstrated. If a field happened to be null in your sample, it is typed as null; if an optional field was present, it is marked required. That is why the result is a first draft to tighten, not a finished contract — feed it a sample that covers the variations you care about, and it will get much closer.
The usual next steps are to relax `required` down to the genuinely mandatory fields, add `format` for emails, dates and URIs, add `enum` where a field only takes a few values, and add ranges with `minimum`, `maxLength` or `minItems`. Once tightened, validate real documents against it on the JSON Schema Validator page.
How to use this tool
- Paste a representative JSON example, or upload a file.
- Choose the JSON Schema draft you are targeting.
- Press Generate schema.
- Review and tighten the schema — add formats, patterns or descriptions — then copy or download it.
Key features
- Draft 2020-12, 2019-09 and Draft-07 output
- Required keys captured from the example
- Array item schemas merged across all elements
- Integer and number types distinguished
- Optional generated title field
Example
Input — JSON
{"id":1,"name":"Ada","active":true}Output — JSON Schema
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"id": { "type": "integer" },
"name": { "type": "string" },
"active": { "type": "boolean" }
},
"required": [ "active", "id", "name" ]
}Good to know
- A schema inferred from one example is a starting point. Formats, enums, ranges and descriptions still need a human.
- Required keys reflect the example you provided; genuinely optional fields must be adjusted by hand.
Frequently asked questions
Which draft should I choose?
Draft 2020-12 is the current version and a good default. Pick 2019-09 or Draft-07 only if your validator requires it.
Are all properties marked required?
Every key present in the example is marked required, because the tool cannot know which are optional. Remove the ones that should be optional.
Is the JSON uploaded?
No. Schema inference happens in your browser.
How are arrays with mixed element types handled?
The element schemas are merged, so the result accepts every element in your sample. Integer and number unify to number, and genuinely different types become a type union rather than the tool guessing one winner.
A field was null in my sample — why is it typed null?
Because that is all the example showed. Change it by hand to the intended type, or use a sample where the field carries a real value, then regenerate.
What should I add after generating?
Usually `format` for emails, dates and URIs, `enum` for closed value sets, and range keywords such as `minimum` or `minItems`. Then trim `required` to the fields that are genuinely mandatory.
Your data stays on your device
Your data is processed locally in your browser and is not uploaded to our server. This page keeps working after you go offline, because there is nothing to send.