JSON Schema Generator & Validator
Infer a draft-07 schema from a sample payload, then validate other documents against it.
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"name": {
"type": "string"
},
"email": {
"type": "string",
"format": "email"
},
"active": {
"type": "boolean"
},
"score": {
"type": "number"
},
"joined": {
"type": "string",
"format": "date-time"
},
"tags": {
"type": "array",
"items": {
"type": "string"
}
},
"address": {
"type": "object",
"properties": {
"city": {
"type": "string"
},
"postcode": {
"type": "string"
}
},
"required": [
"city",
"postcode"
]
}
},
"required": [
"id",
"name",
"email",
"active",
"score",
"joined",
"tags",
"address"
]
}How to Use
- 1. Paste a representative JSON payload into the input panel.
- 2. Choose whether every field should be marked required.
- 3. Copy the generated draft-07 schema.
- 4. Switch to Validate mode to check other documents against it.
About JSON Schema
A schema turns an informal API contract into something machines can check. Once a payload shape is written down, you can validate requests at the edge of your service, generate documentation, and detect when a provider quietly changes a field type.
Inference from a single example has a built-in limitation worth understanding: a sample shows what can appear, not what must. Optional fields that happen to be present look mandatory, and a field that is null in your sample infers as type null rather than "string or null". Treat the generated schema as a first draft to tighten, not a finished contract.
Arrays are handled by inspecting every element rather than just the first, so a mixed array produces a union instead of a schema that silently rejects most of its own data.
Validation here covers the common draft-07 keywords. Composition keywords — allOf, oneOf, $ref, conditional if/then — are not evaluated, so a schema relying on them needs a full validator library.
Related: JSON Formatter, JSON Diff, and XML Formatter.
Frequently Asked Questions
What is a JSON Schema for?
It describes the expected shape of a JSON document — which fields exist, their types, and which are required. Teams use it to validate API payloads, generate documentation, and catch contract drift between a service and its consumers.
How does the generator infer types?
It walks your sample and records the type of each value. Objects become nested property schemas, arrays are inspected to build a schema for their items, and strings can be tagged with a format such as email, uri, or date-time when they match that pattern.
Why are all fields marked required?
A single sample cannot tell you which fields are optional — everything present looks mandatory. The "Mark all fields required" switch lets you turn that off and treat every property as optional, then tighten it by hand.
Which validation keywords are supported?
The common draft-07 core: type, required, properties, items, enum, const, minimum/maximum, minLength/maxLength, minItems/maxItems, and pattern. Advanced composition keywords such as allOf, oneOf, $ref, and conditional if/then are not evaluated.
Is my data uploaded?
No. Inference and validation run entirely in your browser — nothing is sent to a server.
Was this tool helpful?
More Tools
Related Developer Tools
JS & CSS Minifier
JSON Formatter
Regex Tester
SQL Formatter
You Might Also Like