Toolpuffin

    Loading...

    Up and down to choose, Enter to open, Esc to close.

    What Is JSON Schema? How to Write One (With Examples)

    Updated December 2026

    Written by the Toolpuffin team. Tools in this guide are tested in the browser.

    JSON Schema is a way to describe what a piece of JSON should look like, so that a program can check it. This guide explains the keywords you need first, shows a small example and lists the mistakes people make most often.

    Try the tool: JSON Schema Generator

    What JSON Schema does

    JSON Schema is a vocabulary that you can use to annotate and validate JSON documents. It lets you describe an object's properties, say which fields are required and which are optional, and define the expected formats. A schema checks the structure of the data, not whether the values are true.

    Source: JSON Schema: What is JSON Schema?

    Source: JSON Schema: Get started

    The keywords you need first

    • $schema: says which version of JSON Schema you use, for example https://json-schema.org/draft/2020-12/schema.
    • type: the kind of value, such as object, array, string, number, integer, boolean or null.
    • properties: for an object, the fields it can have and a schema for each one.
    • required: a list of the properties that must be present. Properties are not required by default.
    • additionalProperties: controls what happens with fields that are not listed in properties. Setting it to false forbids them.

    The current version of JSON Schema is 2020-12, which is also the version that the generator below produces.

    A small example

    This schema describes an object with a required text field name and an optional whole number age that cannot be negative, and it forbids other fields:

    • type: object
    • properties: name is a string, age is an integer with a minimum of 0
    • required: name
    • additionalProperties: false

    A document with only a name passes. A document without a name, with an age of -1 or with an extra field fails.

    Build one without typing JSON

    Choose the fields and their types in the generator and copy the schema it produces. It has a strict option that marks every field as required and forbids extra fields. Check the result against your data before you rely on it.

    Some AI services let you give a JSON Schema to shape the answer. Which keywords they accept differs per service, so read the documentation of the service you use.

    Common mistakes

    • Assuming that a listed property is required. Add it to required.
    • Forgetting additionalProperties, so unexpected fields pass without a warning.
    • Using an old $schema address that does not match the keywords you used.
    • Expecting a schema to check meaning, such as whether a price is realistic. It checks only structure.

    More guides