JSON to JSON Schema Converter
Generate JSON Schema schemas from JSON instantly. Optional fields are detected automatically. Runs entirely in your browser.
Input
Output
Ready
Drop a file to load it
About this tool
Paste a JSON sample and get JSON Schema JSON Schema you can use immediately. Emits a draft 2020-12 schema with `required` listing only the keys present in every sample.
When you would use it
- Validating payloads in CI or documenting an API contract
- Bootstrapping models from a real JSON response instead of writing them by hand
- Keeping types in step with an API that has changed
Worked example
{
"id": 4815,
"name": "Ada Lovelace",
"active": true,
"score": 91.5,
"roles": ["admin", "editor"],
"address": { "city": "London", "postcode": "NW1" }
}
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Root",
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"name": {
"type": "string"
},
"active": {
"type": "boolean"
},
"score": {
"type": "number"
},
"roles": {
"type": "array",
"items": {
"type": "string"
}
},
"address": {
"type": "object",
"properties": {
"city": {
"type": "string"
},
"postcode": {
"type": "string"
}
},
"additionalProperties": false,
"required": [
"city",
"postcode"
]
}
},
"additionalProperties": false,
"required": [
"id",
"name",
"active",
…
Things worth knowing
- Every object in an array is merged when inferring the shape, so a field missing from one item is marked optional rather than assumed to always be present.
- Identical nested shapes are de-duplicated into a single type instead of generating near-duplicates.
- Array element types are named from the singular of the field name, so
postsproduces aPosttype. - A sample with more records produces better types, because optional fields only reveal themselves across several examples.
Questions
Frequently asked
How are optional fields detected?
By comparing every object in an array. A key present in some records but not others becomes optional; a key present in all of them is required. This is why passing several records gives better results than one.
Can it handle deeply nested JSON?
Yes. Nested objects become separate named types, referenced from their parent, at any depth.
Is my data uploaded anywhere?
No. Every tool on JSONWorks runs entirely in your browser using JavaScript. Your input is never sent to a server, never logged and never stored. The simplest proof is to disconnect from the internet — the tools keep working. The site does load Google Fonts and a Google Analytics page-view tag, so you will see those two requests in your network tab, but neither receives anything you type or paste.
Related