# JSON Schema

> JSON that describes what other JSON should look like. Tools use it to check data.

**Field:** Software Development  
**Category:** Files & Formats  
**Also known as:** JSON Schema Validation, JSON Schema File

## Think of it like

Think of it like a form with rules. The name box must be filled, and the age box must be a number.

## Definition

JSON Schema is a way to describe what good JSON looks like. The schema is written in JSON too. It lists the fields, their types and which ones are required. A tool can then check any JSON against it and point to each mistake. The current version is called 2020-12. Many APIs and code editors use it to catch bad data early.

## Example

A shop's API checks each order against its schema. An order with the price written as the word ten is turned away with a clear error.

## Example code

```json
{
  "type": "object",
  "properties": {
    "name": { "type": "string" },
    "age": { "type": "integer", "minimum": 0 }
  },
  "required": ["name"]
}
```

The name must be there and be text. The age, if given, is a whole number of zero or more.

## Why it matters

It catches bad data at the door. That stops it before it breaks something deep in the program.

## Common mistake

Leaving out the required list. Without it, every field is optional, so an empty object passes the check.

## Three principles

- **Describes the shape.** It lists fields and their types.
- **Written in JSON.** The rules use the same format.
- **Checks data.** Tools flag every mismatch.

## Related terms

- [JavaScript Object Notation (JSON)](https://learn.benibix.com/term/development/json)
- [Input Validation](https://learn.benibix.com/term/development/input-validation)
- [Serialization](https://learn.benibix.com/term/development/serialization)
- [Database Schema](https://learn.benibix.com/term/development/schema)
- [Structured Output (LLM)](https://learn.benibix.com/term/ai/structured-output)

## Taught in

- [Structured Output and JSON](https://learn.benibix.com/learn/ai-working-with-ai/structured-output-and-json): Prompt Engineering, 10/16
- [Print Mode Output Flags](https://learn.benibix.com/learn/ai-claude-code-commands/print-mode-output-flags): Claude Code Commands, 14/17
- [Serialization and Protobuf](https://learn.benibix.com/learn/development-formats/serialization-and-protobuf): File Formats, 4/11

![On the left, a box called In memory holds name Emma and age 36. An arrow marked serialize leads to two forms in the middle: JSON text of 24 bytes, written out as name Emma and age 36 in curly brackets, and Protobuf bytes of 8 bytes, 0A 04 45 6D 6D 61 10 24. An arrow marked deserialize leads to Another program, which holds the same name and age. A note says a JSON Schema can check the text first.](https://learn.benibix.com/diagrams/dev2-serialization.svg)

---

Source: https://learn.benibix.com/term/development/json-schema
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-18
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
