How the schema is inferred
- Types: each value's JSON type, with
integerfor numbers that are always whole. - Formats: strings get
format: email,uri,uuid,dateordate-timewhen every sample value matches. - Arrays of objects are merged: a property missing from some items isn't required, and a property with different types gets a list of types or
anyOf. - Required: properties present in every sample are listed in
required. - A property that is
nullin every sample is typednull; give it its real type by hand.
How to use the JSON to JSON Schema
- Paste sample JSON, or press Sample. For an array, include several items so optional fields are detected.
- Choose the draft, and whether to require fields and forbid extra properties.
- Copy or download the schema, and refine it: add descriptions, minimums or enums.
Examples
Formats and integers
{"id":"7f3c9a8e-2b1d-4e5f-9a6b-1c2d3e4f5a6b","email":"ada@example.com","age":36,"createdAt":"2026-11-10T09:41:22Z","tags":["math","engines"]}{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid"
},
"email": {
"type": "string",
"format": "email"
},
"age": {
"type": "integer"
},
"createdAt": {
"type": "string",
"format": "date-time"
},
"tags": {
"type": "array",
"items": {
"type": "string"
}
}
},
"required": ["id", "email", "age", "createdAt", "tags"]
}
Array items merged
[{"sku":"BK-12","qty":2,"note":"gift"},{"sku":"PN-03","qty":1.5,"note":null}]{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "array",
"items": {
"type": "object",
"properties": {
"sku": {
"type": "string"
},
"qty": {
"type": "number"
},
"note": {
"type": ["string", "null"]
}
},
"required": ["sku", "qty", "note"]
}
}
qty is number because one item has 1.5, and note is a string in one item and null in the other.
Draft 7, no extra properties
{"name":"web","port":8080}{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"name": {
"type": "string"
},
"port": {
"type": "integer"
}
},
"required": ["name", "port"],
"additionalProperties": false
}
2020-12 or draft 7?
Draft 2020-12 is the current version of JSON Schema, used by OpenAPI 3.1. Draft 7 is older but still the most widely supported, for example by many form builders and editors. The generated keywords mean the same in both; only $schema differs.
Options
- Draft
- 2020-12 (the default, as used by OpenAPI 3.1) or draft 7.
- Title
- An optional title for the root schema.
- Required fields
- List properties present in every sample in
required(on by default). - No extra properties
- Add
additionalProperties: falseto every object, so unknown properties are rejected. - Detect formats
- Add
formatfor emails, URLs, UUIDs, dates and date-times (on by default).
Limitations
- A schema inferred from samples describes only what the samples show: add minimums, maximums, patterns and enums yourself.
- Large numbers and very long arrays are fine, but every item of an array is assumed to have the same kind of structure.
Frequently asked questions
Is my JSON uploaded?
No. The schema is generated in your browser; nothing you paste is sent anywhere.
Does the sample pass the generated schema?
Yes, always: the schema is built so that the JSON it was generated from is valid. Check it, or other documents, with the JSON Schema Validator.
Can I generate TypeScript types or Zod schemas instead?
Yes: use JSON to TypeScript or JSON to Zod Schema, which use the same inference.