How to use
- Paste a JSON sample, or click Load sample.
- Set the title for the root schema.
- Copy or download the schema, then add constraints such as formats, patterns and ranges.
Options explained
- Root type name
- Used as the schema's title.
Examples
{"id": 1, "email": null} becomes a schema with "id": {"type": "integer"}, "email": {"type": "null"} and both keys in required.
Example
Two user records, where only the first has an email and manager is sometimes null:
[
{ "id": 1, "name": "Ada", "email": "ada@example.com", "tags": ["admin"], "manager": null },
{ "id": 2, "name": "Grace", "tags": [], "manager": { "id": 1 } }
]
With the root type name set to User, the generated schema is:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "User",
"type": "array",
"items": {
"type": "object",
"properties": {
"id": { "type": "integer" },
"name": { "type": "string" },
"email": { "type": "string" },
"tags": { "type": "array", "items": { "type": "string" } },
"manager": {
"anyOf": [
{ "type": "null" },
{ "type": "object", "properties": { "id": { "type": "integer" } }, "required": ["id"] }
]
}
},
"required": ["id", "name", "tags", "manager"]
}
}
email is left out of required because the second record does not have it, and manager accepts either null or an object because both appear in the sample. The more varied your sample data, the more accurate the schema — paste several records rather than one.
Common uses
Validating API input. Load the schema into a validator such as Ajv (JavaScript) or jsonschema (Python) and reject requests that do not match.
Documenting an API. Paste the properties into an OpenAPI components.schemas section as a starting point.
Editor autocompletion. VS Code and JetBrains IDEs can use a JSON Schema to suggest keys and flag mistakes in JSON configuration files.
Frequently asked questions
Which keys are marked as required?
Keys present in every sample object. When an array contains objects with different keys, keys missing from some items are left out of required.
Can I use it with OpenAPI?
OpenAPI 3.1 uses JSON Schema 2020-12, so the generated schema fits under components/schemas. For OpenAPI 3.0, replace type arrays such as ["string", "null"] with nullable true.
Does it detect formats like email or date-time?
No. It only infers types. Add format, pattern, minimum and similar keywords by hand where needed.
Is my JSON uploaded?
No. The types are generated in your browser, so API responses with real data stay on your device.
Privacy
This tool runs entirely in your browser. Your files and text are processed on your device and are never uploaded to our servers.