Updated June 29, 2026
JSON Schema keywords
JSON Schema validates data using keywords. These are the ones you reach for most, grouped by what they apply to. Combine them to describe required fields, value types, and constraints.
Types and general
| Keyword | Applies to | What it does |
|---|---|---|
type | Any | Restricts the value's type: object, array, string, number, integer, boolean, or null. |
enum | Any | Limits the value to a fixed list of allowed values. |
const | Any | Requires the value to equal one exact value. |
default | Any | Suggests a default; annotation only, not enforced. |
Objects
| Keyword | Applies to | What it does |
|---|---|---|
properties | object | Defines a schema for each named property. |
required | object | Lists properties that must be present. |
additionalProperties | object | Allows or forbids properties not listed in properties. |
minProperties / maxProperties | object | Limits the number of properties. |
Arrays
| Keyword | Applies to | What it does |
|---|---|---|
items | array | Schema that every array element must match. |
minItems / maxItems | array | Limits the array length. |
uniqueItems | array | Requires all elements to be unique when true. |
Numbers and strings
| Keyword | Applies to | What it does |
|---|---|---|
minimum / maximum | number | Inclusive lower and upper bounds. |
multipleOf | number | Requires the value to be a multiple of a given number. |
minLength / maxLength | string | Limits the string length. |
pattern | string | Requires the string to match a regular expression. |
format | string | Hints at a format such as email, date-time, or uri. |
Snippet: required fields with types
A common object schema with required, typed properties.
{
"type": "object",
"required": ["id", "name"],
"properties": {
"id": { "type": "integer" },
"name": { "type": "string", "minLength": 1 }
},
"additionalProperties": false
}Snippet: email and enum
A string with an email format and a field limited to set values.
{
"type": "object",
"properties": {
"email": { "type": "string", "format": "email" },
"role": { "type": "string", "enum": ["admin", "editor", "viewer"] }
}
}Snippet: array of objects
An array whose items each follow a schema.
{
"type": "array",
"items": {
"type": "object",
"required": ["sku"],
"properties": {
"sku": { "type": "string" },
"qty": { "type": "integer", "minimum": 1 }
}
}
}Combining schemas
allOf, anyOf, and oneOf combine subschemas, and not negates one. They let you express unions and conditional rules.References
Questions
Does 'required' make a property exist?
required lists which properties must be present for the data to be valid; it does not create them. A document missing a required property fails validation.
What is the difference between anyOf and oneOf?
anyOf passes if the data matches at least one subschema; oneOf passes only if it matches exactly one. Use oneOf for mutually exclusive options.