JSON Schema Generator — from Sample JSON
Generate a JSON Schema (draft 2020-12) from real JSON: types, nested properties, array items, required keys inferred from your samples, and formats such as email, date, uri and uuid.
JSON Schema Generator
Runs in your browser — nothing you enter is uploaded or stored.
Scratchpad auto-saved
How it works — in four simple steps
No signup and nothing to install — it all runs in your browser.
Add your JSON
Paste it into the left box, press Open file, or drag a .json file onto it. Sample loads a realistic example.
Set the options
Adjust the options above the boxes — the output updates instantly as you change them.
Check the result
Read the status line: it reports rows, keys and any value that couldn't be represented in JSON Schema.
Copy or download
Copy the JSON Schema or download it as a .json file. Nothing was uploaded at any point.
Paste several records — required keys are those present in every one of them.
Features
Required keys inferred
A key is marked required only if it appears in every object you pasted — or force every key to be required.
Strict mode
Add additionalProperties: false to reject unexpected keys during validation.
Example values
Optionally add an examples array to each simple field, taken from the first real value in your data.
Private by design
Parsing and conversion run in your browser with JavaScript — your data is never uploaded, logged or stored.
About the JSON Schema Generator
A JSON Schema describes what valid JSON looks like, and it's used everywhere: request validation in APIs (OpenAPI 3.1 uses JSON Schema 2020-12 directly), form generation, config-file validation in editors like VS Code, and data contracts between teams. Writing one from scratch is tedious; inferring it from a sample gets you 90% of the way in a second.
The generator merges every value it sees at each position. A property's type is the set of JSON types observed (integer and number merge to number; a sometimes-null field gets ["string", "null"]). For arrays of objects, a key is listed in required only if it appears in every object, which is the main reason to paste several records. Strings whose values all look like an email, a URI, a UUID, an IPv4 address, a date or a date-time get the matching format.
Options let you mark every key required, forbid unknown keys with additionalProperties: false, add a title, and include an examples value for each simple field taken from your data. The output declares "$schema": "https://json-schema.org/draft/2020-12/schema".
Examples
Three sign-up records: one lacks a phone number, one has a null referrer, and the strings include emails, dates and a URL.
[
{ "id": "3f1c9a2e-8b7d-4c1e-9f2a-1b2c3d4e5f60", "email": "ada@example.com", "signedUp": "2026-10-19", "plan": "pro", "seats": 5, "referrer": "https://news.example.com" },
{ "id": "9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d", "email": "alan@example.com", "signedUp": "2026-10-20", "plan": "free", "seats": 1, "referrer": null, "phone": "+447700900123" },
{ "id": "0f1e2d3c-4b5a-4968-8776-655443322110", "email": "grace@example.com", "signedUp": "2026-10-21", "plan": "team", "seats": 12.5, "referrer": "https://blog.example.org/post" }
]{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Signup",
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid"
},
"email": {
"type": "string",
"format": "email"
},
"signedUp": {
"type": "string",
"format": "date"
},
"plan": {
"type": "string"
},
"seats": {
"type": "number"
},
"referrer": {
"type": [
"string",
"null"
],
"format": "uri"
},
"phone": {
"type": "string"
}
},
"required": [
"id",
"email",
"signedUp",
"plan",
"seats",
"referrer"
]
}
}This output was produced by the converter on this page with title “Signup” — load it with the “Sign-ups” preset above and change any option to see the effect.
How JSON maps to JSON Schema
| In JSON | Becomes in JSON Schema |
|---|---|
"age": 36 | {"type": "integer"} |
| Ints and floats mixed | {"type": "number"} |
Sometimes null | {"type": ["string", "null"]} |
| Key present in every object | listed in required |
"ada@example.com" | "format": "email" |
"2026-10-21" | "format": "date" |
| Array | {"type": "array", "items": {…}} |
Things that trip people up
- format is an annotation by default. In draft 2020-12, validators don't enforce format unless you enable format assertion (e.g. Ajv's ajv-formats). Check your validator's settings.
- Inferred from a sample. Enums, minimum/maximum, string lengths and patterns can't be guessed reliably — add them by hand where they matter.
- Draft compatibility. Some older tools only understand draft-07. The keywords generated here (type, properties, required, items, format) exist in draft-07 too; change $schema if needed.
- Tuples. Arrays are treated as lists of one item type. For fixed-position tuples, replace items with prefixItems.
JSON vs JSON Schema at a glance
| Property | JSON | JSON Schema |
|---|---|---|
| Specification | RFC 8259 (2017) · ECMA-404 | JSON Schema 2020-12 |
| File extension | .json | .json |
| Media type | application/json | application/schema+json |
| Data types | string, number, boolean, null, object, array | type, properties, items, required, format |
| Comments | No | $comment |
| Nesting | Unlimited | Unlimited |
- JSON: Numbers are parsed as IEEE-754 doubles in JavaScript, so integers above 9,007,199,254,740,991 (2⁵³ − 1) lose precision.