Generator
JSON Schema Generator
Paste example JSON and get a JSON Schema that describes it, ready to use for validation, documentation or API contracts.
How to generate a schema
- Paste one example of your JSON. For arrays, include several items so every variation is seen.
- Choose the options: which keys are
required, whether extra keys are allowed, and whether to detect string formats. - Copy the schema or download
schema.json.
What JSON Schema is for
JSON Schema is a standard way to describe what valid JSON looks like: which keys exist, their types, which are required, and constraints like formats or ranges. Libraries such as Ajv (JavaScript) and jsonschema (Python) use it to validate data, OpenAPI uses it to describe API requests and responses, and editors like VS Code use it for autocompletion in config files.
How the schema is inferred
- Whole numbers become
"integer", other numbers"number". - A key that is missing from some array items is left out of
required. - A value that was null in some places gets a type list such as
["string", "null"]. - Strings that all look like dates, emails, URLs or UUIDs get a
format. - With No extra keys on, objects get
"additionalProperties": false, so unexpected keys fail validation.
Refine it by hand
A generated schema only knows what it saw in the example. After generating, add the rules
you know about: minimum and maximum for numbers,
enum for fixed sets of values, pattern for IDs, and
description fields for documentation.
Frequently asked questions
Which JSON Schema version is generated?
Draft 2020-12, the current version, declared with the $schema keyword. The keywords used here also work in draft-07 validators.
Is the format keyword enforced?
Not always. In draft 2020-12, format is an annotation by default, so some validators only check it when format validation is enabled, for example ajv-formats in Ajv.
Can I use this schema with OpenAPI?
Yes. OpenAPI 3.1 uses JSON Schema 2020-12 directly, so you can paste the schema into components.schemas (without the $schema line).
Why is a key not required?
It was missing from at least one object in an array, or you turned off the required option.
Is my data uploaded?
No. Everything runs with JavaScript inside your browser tab. Nothing you paste is sent to a server or stored.