JSON Schema generator
schema.json
A schema for 12 properties, 2 levels deep.
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Product",
"type": "object",
"properties": {
"name": {
"type": "string"
},
"price": {
"type": "number"
},
"in_stock": {
"type": "boolean"
},
"quantity": {
"type": "integer"
},
"tags": {
"type": "array",
"items": {
"type": "string"
}
},
"dimensions": {
"type": "object",
"properties": {
"height_cm": {
"type": "integer"
},
"width_cm": {
"type": "number"
}
},
"required": [
"height_cm",
"width_cm"
]
},
"variants": {
"type": "array",
"items": {
"type": "object",
"properties": {
"colour": {
"type": "string"
},
"sku": {
"type": "string"
},
"limited": {
"type": "boolean"
}
},
"required": [
"colour",
"sku"
]
}
}
},
"required": [
"name",
"price",
"in_stock",
"quantity",
"tags",
"dimensions",
"variants"
]
}- Note: Whole numbers are typed integer. If a field can hold decimals, such as a price that happens to be 12 in the sample, change it to number.
How to use it · free, no signup
How to use the JSON Schema Generator
Paste a sample JSON document and get a JSON Schema describing it: types, properties, required fields and array items, with a strict mode for AI structured output. Runs in your browser.
01
Paste a sample
One realistic JSON document, with every field you expect.
02
Choose the options
Version, required fields, extra properties, formats, strict mode.
03
Copy the schema
Then check the notes for anything a sample cannot show.
What a schema describes
A JSON Schema is a description of what a valid document looks like: the properties it may contain, the type of each one, which are required and what the items of each list look like. It is defined by the JSON Schema specification, and it is used in two common ways: to validate data before a program trusts it, and to tell an AI model exactly what shape its answer must take.
How the sample becomes a schema
| In the sample | In the schema |
|---|---|
"Ceramic coffee cup" | "type": "string" |
18.5 | "type": "number" |
24 | "type": "integer" |
true | "type": "boolean" |
["kitchen", "gift"] | An array whose items are strings |
{ "height_cm": 9, … } | An object with its own properties |
| Two variants, one with "limited" | One item schema; colour and sku required, limited optional |
Arrays of objects are merged into a single item schema. That is how a list where only some items carry a field produces a schema in which that field is optional rather than missing.
Strict mode for structured output
AI providers that guarantee output matching a schema accept only part of JSON Schema in their strict modes. Microsoft’s guide to structured outputs in Azure OpenAI lists the rules: every field required, additionalProperties set to false on every object, optional values written as a union with null, no keywords such as format, minimum or pattern, and at most 100 properties and five levels of nesting. The strict option applies those rules. Check your own provider’s documentation before relying on them, because the details differ and change.
Check what a sample cannot show
- Whole numbers are typed integer. A price that happens to be 12 in the sample should be number.
- Null values have no knowable type. Replace "null" with what the field holds when it is filled.
- Empty arrays have no item schema. Add one example item to the sample.
- Fixed lists of values, such as a status that can only be draft or sent, need an enum added by hand.
To ask a model for output in this shape, describe the task with the AI prompt generator and attach the schema. Long schemas count towards the model’s input; the token counter estimates their size.
Published by Koit Academy. Who runs it, how it is paid and how its tools are checked.
Questions
What people ask about the JSON Schema Generator
What is a JSON Schema?
Which version should I choose?
How are arrays of objects handled?
What does strict mode do?
Why is a field typed integer when it should be a number?
Related tools
Token Counter
An estimate of the tokens in any text
Open itAI Prompt Generator
One clear prompt from its parts
Open itPassword Generator
Generate strong passwords in your browser and see what they are actually worth
Open itAI Image Prompt Generator
A detailed image prompt from its parts
Open itAI Text Cleaner
Plain text from an AI answer, without the Markdown
Open itAI API Cost Calculator
What an AI workload costs per request and per month
Open it