JSON Schema generator
Turn real samples into an accurate JSON Schema and test it with other documents without leaving the page.
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"email": {
"type": "string",
"format": "email"
},
"role": {
"type": "string"
},
"createdAt": {
"type": "string",
"format": "date-time"
},
"tags": {
"type": "array",
"items": {
"type": "string"
}
},
"profile": {
"type": "object",
"properties": {
"city": {
"type": "string"
},
"zip": {
"type": "string"
}
},
"required": [
"city"
]
},
"phone": {
"type": "null"
}
},
"required": [
"id",
"email",
"role",
"createdAt",
"tags",
"profile"
]
}Test the schema with another JSON
5 errors
- /id — wrong type, expected integer
- /email — does not match format email
- /createdAt — does not match format date-time
- /tags/0 — wrong type, expected string
- /profile — missing required property "city"
Limits
- The schema describes the samples you give: an observed enum or range may be too strict for future data. Review it before publishing.
- The built-in validator covers the keywords the tool generates (type, properties, required, items, anyOf, enum, format, ranges). For hand-written schemas with $ref, oneOf or patterns use a full validator such as Ajv.
- Output has been cross-checked with Ajv on hundreds of valid and mutated documents.
- Everything runs in your browser.
Built by
Miguel Ángel Colorado Marin (MACM)
Built by
Miguel Ángel Colorado Marin (MACM)
Full-Stack Developer · Guadalajara, España
I develop web apps, digital tools and full projects — from design to deployment.
Writing a JSON Schema by hand for an API or a config file is tedious: you have to decide types, required fields, formats and nulls one by one. This generator infers them from real samples. With several samples it tells which properties always appear and which are optional, which fields allow null and when a value changes type. Then you can paste another document and instantly see what fails and at which path, something most generators do not offer. Output has been cross-checked with Ajv on hundreds of valid and mutated documents.
Features
- ✓JSON Schema draft 2020-12 or draft-07 with optional $id and title
- ✓Merges several samples: required only for keys present in all of them
- ✓Nullable types such as ["string", "null"] and anyOf when a field mixes objects, arrays and values
- ✓Detects email, uri, uuid, date, date-time, ipv4 and ipv6 formats
- ✓Automatic enum for repeated values with a configurable limit
- ✓Optional observed minimum, maximum, lengths and item counts
- ✓additionalProperties: false for strict schemas and optional examples
- ✓Built-in validator to test the schema with another JSON and see every error by path
How do I generate a JSON Schema from JSON?
- 1
Paste one or more samples
Paste an object or an array of objects. If the root array holds separate samples, keep that option on.
- 2
Configure the schema
Pick the draft, required criterion, formats, enum, ranges and whether extra properties are allowed.
- 3
Review and export
Copy the schema or download it as schema.json.
- 4
Test it
Paste another JSON into the validator to check the schema accepts and rejects what you expect.
Frequently asked questions
What is a JSON Schema?
It is a standard for describing a JSON document's structure: types, required properties, formats and constraints. It is used to validate API requests, document contracts in OpenAPI and power editor autocompletion.
Should I use draft 2020-12 or draft-07?
2020-12 is the current version and the one used by OpenAPI 3.1. Draft-07 is still very common in older validators and editor configs. For the keywords this tool generates the structure is the same and only the $schema URL changes.
How does it decide which properties are required?
By default a property is required when it appears in every analyzed object. You can also mark every key seen as required, or none.
Why can enum or ranges be risky?
Because they only describe the sample data. If your samples contain the roles admin and user, a valid third role in production would fail. Enable them when the samples are representative.
Is my data sent to a server?
No. Generation and validation happen in your browser.
Related tools
Embed JSON Schema Generator on your site
Add JSON Schema Generator to any web page with a simple iframe. Free, with attribution to miguelacm.es.
<iframe
src="https://miguelacm.es/embed/json-schema-generator"
width="100%"
height="700"
frameborder="0"
title="JSON Schema Generator — miguelacm.es"
></iframe>View embed in new tab →