JSON Schema Generator
Generate a JSON Schema (draft 2020-12 or draft-07) from sample JSON. Merges array items, marks optional keys, detects integers, nullable values, and string formats.
Processed locally in your browser — nothing is uploaded.
JSON Schema Generator
0 characters
JSON Schema
Output appears here…About the JSON Schema Generator
Paste a sample JSON document (an API response, a config file, a webhook payload) and get a JSON Schema that describes it. Whole numbers become integer and the rest number, nested objects get their own properties, and every item of an array is merged into one items schema — so a key present in every item is required, while a key that only some items have is optional.
Values that change type are written as a type array, like ["string", "null"] for a field that is sometimes null. When objects and arrays turn up in the same place, the schema uses anyOf instead. Strings can be checked for a common format: date-time, date, time, email, uri, uuid, or ipv4.
Choose draft 2020-12 or draft-07 for the $schema keyword, add a title, leave every property optional, or close objects with additionalProperties: false.
Common uses
- Start a schema for validating requests or responses in an API
- Document the shape of a config file or webhook payload
- Bootstrap the schema section of an OpenAPI spec or a form generator
Example
Input
[
{"id": 1, "email": "ada@example.com"},
{"id": 2, "email": null, "admin": true}
]Output
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "array",
"items": {
"type": "object",
"properties": {
"id": { "type": "integer" },
"email": { "type": ["string", "null"], "format": "email" },
"admin": { "type": "boolean" }
},
"required": ["id", "email"]
}
}The output is compacted here; the tool pretty-prints every keyword on its own line.
Limitations
- The schema describes only what the sample shows — a field that can be absent, null, or another type in other documents is marked that way only if the sample includes such a case
- It doesn't infer value constraints like
minimum,maxLength,enum, orpattern; add those by hand - JSON doesn't distinguish
1.0from1, so1.0is read as an integer - Empty arrays get no
itemsschema, and empty objects noproperties, because there's nothing to infer from
Frequently asked questions
How does the generator decide which properties are required?
It compares every object found at the same place in the document — typically the items of an array. A key present in all of them is listed in required; a key present in only some is left optional. A single object has all of its keys required. You can also switch required off entirely.
Should I choose draft 2020-12 or draft-07?
Use whichever your validator or tooling supports. Draft 2020-12 is the current version and is used by OpenAPI 3.1; draft-07 is older but still widely supported. The schemas this tool generates use only keywords that mean the same thing in both, so only the $schema line changes.
Will a validator check the format keyword?
Not necessarily. JSON Schema doesn't require validators to enforce format, and in draft 2020-12 it's an annotation by default. Many validators check formats only when you enable it — Ajv, for example, needs the ajv-formats plugin. Turn format detection off if you don't want format in the output.
Why does a time like 14:30:00 get no format?
JSON Schema's time format follows RFC 3339, where a time includes a UTC offset, such as 14:30:00Z or 14:30:00+02:00. A bare 14:30:00 doesn't match it, so the generator leaves it as a plain string rather than produce a schema your own data would fail.
What does additionalProperties: false do?
It makes an object reject any key that isn't listed in its properties, which catches typos and unexpected fields. It's also strict: an API that adds a field later would fail validation, so only turn it on when you want a closed shape.
Is my JSON uploaded anywhere?
No. The JSON is parsed and the schema is generated entirely in your browser, so payloads containing real data never leave your device.