JSON to JSON Schema Generator
Generate a draft 2020-12 JSON Schema from a sample: types, required keys, nested objects and additionalProperties false.
What the JSON Schema generator does
The schema is written for draft 2020-12. A whole number becomes type integer and a decimal becomes number, because the two are different JSON types. A key that is absent from some array elements is left out of required; a key that was present and null is required and its type includes null. additionalProperties is false at every object level, so a validator rejects keys the sample never showed — which is the useful strictness for an API contract and the wrong default for a log payload, so check it before publishing.
How to use it
JSON to JSON Schema Generator: paste the JSON into the box above, set Schema title (default "Root"), and press Run to get the JSON Schema below.
Worked example
Input:
{
"id": 42,
"displayName": "Ada Lovelace",
"active": true,
"score": 9.5,
"tags": [
"math",
"engine"
],
"address": {
"city": "London",
"country": "GB"
},
"projects": [
{
"name": "Analytical Engine",
"year": 1843
},
{
"name": "Note G",
"year": 1843,
"notes": "first published algorithm"
}
],
"nickname": null
}
Output:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Root",
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"displayName": {
"type": "string"
},
"active": {
"type": "boolean"
},
"score": {
"type": "number"
},
"tags": {
"type": "array",
"items": {
"type": "string"
}
},
"address": {
"type": "object",
"properties": {
"city": {
"type": "string"
},
"country": {
"type": "string"
}
},
"additionalProperties": false,
"required": [
"city",
"country"
]
},
"projects": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"year": {
"type": "integer"
},
"notes": {
"type": "string"
}
},
"additionalProperties": false,
"required": [
"name",
"year"
]
}
},
"nickname": {
"type": [
"null",
"null"
]
}
},
"additionalProperties": false,
"required": [
"id",
"displayName",
"active",
"score",
"tags",
"address",
"projects",
"nickname"
]
}
Why it runs in your browser
The conversion happens on this page with JavaScript. Your input is not posted to a server, so it works offline after the page loads and nothing is retained anywhere. The page reads JSON and returns JSON Schema; reloading the page discards both.
The schema is written for draft 2020-12. A whole number becomes type integer and a decimal becomes number, because the two are different JSON types. A key that is absent from some array elements is left out of required; a key that was present and null is required and its type includes null. additionalProperties is false at every object level, so a validator rejects keys the sample never showed — which is the useful strictness for an API contract and the wrong default for a log payload, so check it before publishing.
Generate a draft 2020-12 JSON Schema from a sample: types, required keys, nested objects and additionalProperties false.
How to use it
JSON to JSON Schema Generator: paste the JSON into the box above, set Schema title (default "Root"), and press Run to get the JSON Schema below.
Why it runs in your browser
The conversion happens on this page with JavaScript. Your input is not posted to a server, so it works offline after the page loads and nothing is retained anywhere. The page reads JSON and returns JSON Schema; reloading the page discards both.
What to Expect
Best for
- Converting JSON to JSON Schema when the data is already on screen.
What this tool keeps
- Your input is not posted to a server, so it works offline after the page loads and nothing is retained anywhere.
Sample input
{ "id": 42, "displayName": "Ada Lovelace", "active": true, "score": 9.5, "tags": [ "math", "engine" ], "address": { "city": "London", "country": "GB" }, "projects": [ { "name": "Analytical Engine", "year": 1843 }, { "name": "Note G", "year": 1843, "notes": "first published algorithm" } ], "nickname": null }
Sample output
{ "$schema": "https://json-schema.org/draft/2020-12/schema", "title": "Root", "type": "object", "properties": { "id": { "type": "integer" }, "displayName": { "type": "string" }, "active": { "type": "boolean" }, "score": { "type": "number" }, "tags": { "type": "array", "items": { "type": "string" } }, "address": { "type": "object", "properties": { "city": { "type": "string" }, "country": { "type": "string" } }, "additionalProperties": false, "required": [ "city", "country" ] }, "projects": { "type": "array", "items": { "type": "object", "properties": { "name": { "type": "string" }, "year": { "type": "integer" }, "notes": { "type": "string" } }, "additionalProperties": false, "required": [ "name", "year" ] } }, "nickname": { "type": [ "null", "null" ] } }, "additionalProperties": false, "required": [ "id", "displayName", "active", "score", "tags", "address", "projects", "nickname" ] }
Frequently asked questions
How do I use the json to json schema generator?
JSON to JSON Schema Generator: paste the JSON into the box above, set Schema title (default "Root"), and press Run to get the JSON Schema below.
Is my input uploaded?
No. The text is parsed on this page with JavaScript and is never posted to a server.
Is there a size limit?
Yes: 5 MB per run. Larger input is refused with a message rather than freezing the tab.
Build custom tools for your store
Join the SDK program to create useful ecommerce utilities for your store.