Output will appear here
Output will appear here
Paste sample JSON and get a JSON Schema (draft 2020-12) that describes it. Every array element is merged, so required lists only the keys present in all records. Nullable values become ["string", "null"]. Strings that look like an email, URI, UUID, date or timestamp get a format, and a value that repeats a small set of strings gets an enum.
By Ankit Aglawe · Updated · Runs entirely in your browser
Nested objects are written inline, each with its own properties and required. Ports and counts are integer while burst is number, so a validator rejects port: 84.5. The origins get format: "uri". Point your editor at the schema and it will autocomplete and check the config.
{
"service": "checkout-api",
"port": 8443,
"debug": false,
"database": { "host": "db.internal", "port": 5432, "poolSize": 20, "sslmode": "require" },
"cors": { "allowedOrigins": ["https://shop.example.com", "https://admin.example.com"], "maxAgeSeconds": 600 },
"rateLimit": { "requestsPerMinute": 120, "burst": 1.5 },
"featureFlags": { "newCart": true, "applePay": false }
}{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"service": {
"type": "string"
},
"port": {
"type": "integer"
},
"debug": {
"type": "boolean"
},
"database": {
"type": "object",
"properties": {
"host": {
"type": "string"
},
"port": {
"type": "integer"
},
"poolSize": {
"type": "integer"
},
"sslmode": {
"type": "string"
}
},
"required": [
"host",
"port",
"poolSize",
"sslmode"
]
},
"cors": {
"type": "object",
"properties": {
"allowedOrigins": {
"type": "array",
"items": {
"type": "string",
"format": "uri"
}
},
"maxAgeSeconds": {
"type": "integer"
}
},
"required": [
"allowedOrigins",
"maxAgeSeconds"
]
},
"rateLimit": {
"type": "object",
"properties": {
"requestsPerMinute": {
"type": "integer"
},
"burst": {
"type": "number"
}
},
"required": [
"requestsPerMinute",
"burst"
]
},
"featureFlags": {
"type": "object",
"properties": {
"newCart": {
"type": "boolean"
},
"applePay": {
"type": "boolean"
}
},
"required": [
"newCart",
"applePay"
]
}
},
"required": [
"service",
"port",
"debug",
"database",
"cors",
"rateLimit",
"featureFlags"
]
}phone is missing from one record, so it is left out of required. Where it appears it can be null, giving "type": ["string", "null"]. lastLogin needs anyOf, because the date-time format belongs to the string branch only. role becomes enum: ["admin", "member"].
[
{ "id": "a7f1c3e2-1b4d-4e8f-9a2b-3c4d5e6f7a8b", "email": "[email protected]", "role": "admin", "lastLogin": "2026-10-27T21:03:00Z", "phone": null },
{ "id": "b8e2d4f3-2c5e-4f9a-8b3c-4d5e6f7a8b9c", "email": "[email protected]", "role": "member", "lastLogin": null, "phone": "+44 20 7946 0958" },
{ "id": "c9f3e5a4-3d6f-4a1b-9c4d-5e6f7a8b9c0d", "email": "[email protected]", "role": "member", "lastLogin": "2026-10-20T08:15:00Z" },
{ "id": "d0a4f6b5-4e7a-4b2c-8d5e-6f7a8b9c0d1e", "email": "[email protected]", "role": "admin", "lastLogin": "2026-10-28T07:44:00Z", "phone": null }
]{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid"
},
"email": {
"type": "string",
"format": "email"
},
"role": {
"type": "string",
"enum": [
"admin",
"member"
]
},
"lastLogin": {
"anyOf": [
{
"type": "string",
"format": "date-time"
},
{
"type": "null"
}
]
},
"phone": {
"type": [
"string",
"null"
]
}
},
"required": [
"id",
"email",
"role",
"lastLogin"
]
}
}Every code generator on this site is run on the same awkward input: a 64-bit id, a float written as 1.0, a null, a date string, a reserved word as a key, an empty array, a nested array and an array of objects whose keys differ. This is the exact output for JSON Schema, generated when the page was built.
{
"id": 9007199254740993,
"price": 19.99,
"ratio": 1.0,
"deleted_at": null,
"created_at": "2024-01-15T10:30:00Z",
"class": "premium",
"tags": [],
"matrix": [[1, 2], [3, 4.5]],
"items": [{ "sku": "A1", "qty": 1 }, { "sku": "B2", "qty": 2, "note": "gift" }]
}{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"price": {
"type": "number"
},
"ratio": {
"type": "integer"
},
"deleted_at": {
"type": "null"
},
"created_at": {
"type": "string",
"format": "date-time"
},
"class": {
"type": "string"
},
"tags": {
"type": "array"
},
"matrix": {
"type": "array",
"items": {
"type": "array",
"items": {
"type": "number"
}
}
},
"items": {
"type": "array",
"items": {
"type": "object",
"properties": {
"sku": {
"type": "string"
},
"qty": {
"type": "integer"
},
"note": {
"type": "string"
}
},
"required": [
"sku",
"qty"
]
}
}
},
"required": [
"id",
"price",
"ratio",
"deleted_at",
"created_at",
"class",
"tags",
"matrix",
"items"
]
}A key is listed in required only if every object in the sample has it. A null value does not make a key optional; it adds "null" to the allowed types. So note in the edge-case output is a property but not required, while deleted_at is required and must be null.
A field that was null in every sample gets "type": "null", which rejects any real value. Loosen it by hand, for example to ["string", "null"], once you know the type.
Whole numbers get "type": "integer", anything with a fraction gets "number", and a field that has both is number. 1.0 counts as an integer, which matches the spec: JSON Schema treats a number with a zero fractional part as an integer. There is no size limit, so 64-bit ids validate.
Property names are copied as-is, so reserved words like class and odd keys like user-name or 2fa need no escaping. The schema does not set additionalProperties, so extra keys in real data still pass. Add "additionalProperties": false if you want them rejected.
Detected formats (date-time, date, email, uri, uuid, ipv4) are written out, but in draft 2020-12 format is only checked if the validator enables it, as Ajv does with ajv-formats. With it enabled, date-time requires a T and a zone, as in 2024-01-15T10:30:00Z.
An empty array becomes { "type": "array" } with no items, because the sample says nothing about its elements. Nested arrays nest items inside items. A mixed array collapses plain types into one list, such as ["string", "integer", "null"].
| JSON value | Schema | Notes |
|---|---|---|
| string | {"type": "string"} | Plus format or enum when detected |
| integer | {"type": "integer"} | |
| float | {"type": "number"} | |
| true / false | {"type": "boolean"} | |
| null alongside a value | {"type": ["T", "null"]} | anyOf if the branch has a format or enum |
| key in every object | listed in required | |
| object | properties + required | Inline, no $defs |
| array | {"type": "array", "items": ...} | All elements merged |
| empty array | {"type": "array"} |
Paste a representative JSON object in the input editor. The richer your sample data, the more accurate the generated schema will be.
The output shows a JSON Schema 2020-12 definition with type constraints, required fields, format annotations, and nested object schemas.
Copy the schema or download the .json file. Use it for API documentation (OpenAPI), form validation, or CI pipelines that validate config files.
Paste one or more sample documents (an array of records works best) and copy the schema from the right pane. The more samples you include, the more accurate required and the types become.
Draft 2020-12, declared with $schema. Every fixture in the project tests is checked so the generated schema accepts the sample it was built from.
Yes. Import Ajv2020 from ajv/dist/2020, compile the schema, and add ajv-formats if you want format values such as email enforced.
At least one object in your sample did not have that key. If the key is in fact always sent, add it to required by hand or paste a sample where every record has it.
No. additionalProperties is not set, so data with extra keys still validates. Add "additionalProperties": false to an object to make it strict.
Validate API payloads, add editor autocomplete for a config file via $schema or a VS Code setting, or feed it to tools that generate forms, docs or types from JSON Schema.
Need several formats at once? Convert All shows every output from one paste. Or browse all JSON converters.