From example data to a validation contract
JSON Schema describes what valid JSON looks like: which properties exist, what type each one has and which are required. It is used to validate API requests, document OpenAPI specifications, power form generators and catch bad configuration early. Writing a schema by hand for a large object takes a long time — generating a first draft from real data takes a second.
The generator walks your sample and records the type of every value. For arrays it merges all items: a property is listed as required only if every object contains it, and a property that is sometimes a string and sometimes null gets "type": ["string", "null"]. Strings that all look like dates, date-times, emails, URLs or UUIDs receive a matching format.
How to use it
- Paste one or more representative JSON documents (wrap several in an array to merge them).
- Choose the draft version your validator supports — Ajv, Python
jsonschemaand most modern tools support 2020-12; older tools may need Draft-07. - Review the result: add
minimum,maxLength,enumorpatternrules where your data has business constraints.
Example
JSON
{"id": 7, "email": "a@b.co", "tags": ["x"]}Schema
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Root",
"type": "object",
"properties": {
"id": { "type": "integer" },
"email": { "type": "string", "format": "email" },
"tags": { "type": "array", "items": { "type": "string" } }
},
"required": ["id", "email", "tags"]
}Frequently asked questions
Is the generated schema complete?
It is a strong starting point that matches your sample. A sample cannot reveal business rules such as value ranges or allowed values, so add those yourself.
What does additionalProperties: false do?
It makes validation fail when an object contains a key that is not listed in the schema. Useful for strict APIs, but it can break when new fields are added.
Integer or number?
Whole numbers become integer. If any value in the same position has decimals, the type becomes number.
Is my data uploaded?
No. The schema is generated in your browser.