JSON Schema Generator
Infer Draft-07 JSON Schema from sample data
JSON Sample
Generated Schema
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "MySchema",
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"name": {
"type": "string",
"minLength": 0
},
"email": {
"type": "string",
"format": "email",
"minLength": 0
},
"age": {
"type": "integer"
},
"active": {
"type": "boolean"
},
"score": {
"type": "number"
},
"tags": {
"type": "array",
"items": {
"type": "string",
"minLength": 0
}
},
"address": {
"type": "object",
"properties": {
"street": {
"type": "string",
"minLength": 0
},
"city": {
"type": "string",
"minLength": 0
},
"postalCode": {
"type": "string",
"minLength": 0
}
},
"required": [
"street",
"city",
"postalCode"
]
},
"metadata": {
"type": [
"string",
"number",
"boolean",
"object",
"array",
"null"
]
}
},
"required": [
"id",
"name",
"email",
"age",
"active",
"score",
"tags",
"address"
]
}About the JSON Schema Generator
This JSON Schema generator infers a draft schema from sample JSON, deducing types, required fields and nested object definitions. It gives you a working starting point instead of writing the schema from nothing.
A JSON Schema generator saves the tedious first pass. Writing a schema by hand for a response with thirty fields and three levels of nesting is slow and error-prone, while the structure needed is already visible in the data.
What is inferred is types and shape: strings, numbers, booleans, arrays and nested objects, with the keys present in the sample marked required. Nested objects get their own definitions so the schema stays readable rather than becoming one giant block.
Treat the output as a draft. A generator cannot know that a string is really an email, that a number has a valid range, or that a field is optional but happened to be present in your sample. Those constraints are exactly what makes a schema valuable, and they have to be added deliberately.
How to use the JSON Schema Generator
- Paste sample JSON. Provide a representative example of the data.
- Generate the schema. Types, required fields and nested definitions are inferred.
- Refine the constraints. Add formats, ranges and mark genuinely optional fields.
- Copy the schema. Take it into your validation layer or API contract.
JSON Schema Generator features
- Infers a Draft-07 schema from sample JSON
- Types deduced per field
- Nested objects and arrays described to full depth
- Configurable schema title
- Copy the schema or download it
Frequently asked questions
How does it infer a schema?
By walking your sample and recording what it finds: each field's type, the shape of nested objects, and the item type of arrays. The result is a Draft-07 schema describing the example you gave it.
Can it validate JSON against a schema?
No — this generates schemas rather than checking documents against them. Use a validator library such as Ajv for that, feeding it the schema produced here.
Will the generated schema be right first time?
It is a starting point, not a finished contract. Inference cannot know which fields are genuinely optional, what ranges are valid, or which strings are really enums — a single sample looks like the whole world to it.
What should I add by hand afterwards?
Descriptions, formats such as date-time and email, required-field lists you actually intend, and constraints like minimum, maximum and pattern. That is where a schema starts earning its place.
Why Draft-07?
Because it has the widest tool support. Later drafts exist and are better specified, but Draft-07 is what most validators, editors and code generators handle without complaint.