Skip to content
Koit Academy

JSON Schema generator

Your details

The details filled in are an example. Everything runs in this browser; nothing you type is sent anywhere or stored.

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.

  1. 01

    Paste a sample

    One realistic JSON document, with every field you expect.

  2. 02

    Choose the options

    Version, required fields, extra properties, formats, strict mode.

  3. 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 sampleIn 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?
A JSON document that describes the shape of other JSON documents: which properties exist, what type each one is and which are required. Programs use it to validate data and AI tools use it to constrain their output.
Which version should I choose?
Draft 2020-12 is the current version. Choose draft-07 only if a tool you use says it needs it.
How are arrays of objects handled?
The items are merged into one schema. A key present in every item is required; a key present in only some is optional, or nullable in strict mode.
What does strict mode do?
It applies the rules documented for strict structured outputs: every property required, no extra properties, optional values allowed to be null instead, and no format keywords.
Why is a field typed integer when it should be a number?
Because the sample held a whole number. A sample can only show the values it contains; change the type to number if the field can hold decimals.