Overview
The JSON Schema Validation specification defines a vocabulary for describing the structure and constraints of JSON documents. It provides keywords for validation (assertions) and metadata (annotations) that work together with the Core specification. This specification defines keywords for:- Type validation
- Numeric constraints
- String validation
- Array constraints
- Object validation
- Format semantic validation
- Metadata annotations
Validation keywords are assertions that produce a boolean result. An instance is valid if it satisfies all asserted constraints.
Type Validation
type
The type keyword restricts an instance to one or more primitive types.
Value: A string or array of strings.
Allowed Types:
"null""boolean""object""array""number""string""integer"(numbers with zero fractional part)
"integer" is not a primitive type in the JSON data model but is defined as a convenience for matching numbers with zero fractional parts.enum
Restricts the instance to a fixed set of values.
Value: An array (elements SHOULD be unique).
const
Restricts the instance to a single value.
Value: Any JSON value.
Using
const is functionally equivalent to enum with a single value, but makes the intent clearer.Numeric Validation
Numeric validation keywords apply to bothnumber and integer types. If the instance is not a number, validation succeeds (allowing multi-type schemas).
Range Constraints
minimum and maximum
minimum and maximum
Inclusive bounds for numeric values.Valid:
Invalid:
0, 50, 100Invalid:
-1, 101exclusiveMinimum and exclusiveMaximum
exclusiveMinimum and exclusiveMaximum
Exclusive bounds for numeric values.Valid:
Invalid:
0.1, 0.5, 0.999Invalid:
0, 1multipleOf
Restricts numbers to multiples of a given value.
Value: A number strictly greater than 0.
1.23, 5.67, 0.01Invalid:
1.234
0, 5, 10, -15Invalid:
3, 7
String Validation
String validation keywords only apply when the instance is a string.Length Constraints
minLength and maxLength
minLength and maxLength
Constrain the length of strings (measured in Unicode code points).Valid:
Invalid:
"abc", "hello world"Invalid:
"ab", "this string is way too long"Omitting
minLength is equivalent to a value of 0.pattern
Validates strings against a regular expression.
Value: A string representing a valid ECMA-262 regular expression.
"Hello", "World"Invalid:
"hello", "WORLD"
Regular expressions are not implicitly anchored. The pattern
"es" matches "expression".Array Validation
Array validation keywords only apply when the instance is an array.Size Constraints
minItems and maxItems
minItems and maxItems
Constrain the number of elements in an array.Valid:
Invalid:
[1], [1, 2, 3]Invalid:
[], [1, 2, 3, 4, 5, 6]Omitting
minItems is equivalent to a value of 0.uniqueItems
Requires all array elements to be unique.
Value: A boolean.
[1, 2, 3], ["a", "b", "c"]Invalid:
[1, 2, 1], ["a", "a"]
Omitting this keyword or setting it to
false allows duplicate elements.Object Validation
Object validation keywords only apply when the instance is an object.Size Constraints
minProperties and maxProperties
minProperties and maxProperties
Constrain the number of properties in an object.Valid:
Invalid:
{"a": 1}, {"a": 1, "b": 2}Invalid:
{}, (object with 11 properties)Omitting
minProperties is equivalent to a value of 0.required
Specifies which properties must be present.
Value: An array of strings (MUST be unique).
{"name": "John", "email": "john@example.com"}Invalid:
{"name": "John"}, {"email": "john@example.com"}
dependentRequired
Specifies properties that are required when another property is present.
Value: An object mapping property names to arrays of required property names.
{}(no credit card){"creditCard": "1234", "cvv": "123", "billingAddress": "..."}
{"creditCard": "1234"}(missing cvv and billingAddress){"creditCard": "1234", "cvv": "123"}(missing billingAddress)
Format Validation
Theformat keyword provides semantic validation for strings representing well-known data formats.
Value: A string identifying the format.
Behavior:
- Acts as both an assertion (validation) and annotation
- Implementations SHOULD provide validation for standard formats
- Implementations MUST refuse to process schemas with unsupported formats
Starting with JSON Schema v1/2026,
format is required to provide assertion behavior by default. This is a change from previous drafts where it was annotation-only.Date and Time Formats
Based on RFC 3339 and RFC 9557:date-time:2026-03-03T14:30:00Zdate:2026-03-03time:14:30:00duration:P3Y6M4DT12H30M5S
Email Format
user@example.com
Hostname Format
example.com, api.example.com
IP Address Formats
ipv4:192.168.1.1ipv6:2001:0db8:85a3:0000:0000:8a2e:0370:7334
Resource Identifier Formats
uri:https://example.com/pathuri-reference:/path/to/resourceorhttps://example.comiri: International Resource Identifieriri-reference: IRI or relative referenceuuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6
Other Formats
uri-template
uri-template
https://example.com/users/{id}json-pointer
json-pointer
/properties/name, /items/0relative-json-pointer
relative-json-pointer
0/name, 1/items/0regex
regex
Content Keywords
Content keywords annotate strings containing non-JSON data encoded within JSON strings.Important: These are annotation-only keywords. Implementations MUST NOT automatically decode, parse, or validate the content due to security and performance concerns.
contentEncoding
Indicates that a string should be interpreted as encoded binary data.
Value: A string (e.g., "base64", "base32", "base16").
contentMediaType
Indicates the media type of string contents.
Value: A media type string (RFC 2046).
contentSchema
Describes the structure of string contents (when contentMediaType is present).
Value: A valid JSON schema.
Example: Base64-Encoded Image
Example: JWT Token
Metadata Annotations
Metadata keywords provide information for documentation and user interfaces. They do not affect validation.title and description
default
Provides a default value (annotation only).
The
default value is RECOMMENDED to be valid against the schema, but this is not enforced.deprecated
Indicates that a property or schema should no longer be used.
Value: A boolean.
readOnly and writeOnly
Indicate data flow restrictions.
readOnly: true- Value is managed by the owning authority, modification attempts should be ignoredwriteOnly: true- Value is never returned when retrieved from the owning authority
examples
Provides sample values.
Value: An array.
Assertion vs Annotation Behavior
JSON Schema keywords exhibit different behaviors:Assertions
Produce a boolean result (true or false):
type,minimum,maximum,minLength,maxLengthpattern,minItems,maxItems,requiredformat(as of v1/2026)
Annotations
Attach metadata to instance locations:title,description,defaultdeprecated,readOnly,writeOnly,examplescontentEncoding,contentMediaType,contentSchema
Schemas that fail validation MUST NOT produce annotation results, even from their annotation keywords.
Complete Example
Here’s a comprehensive schema using validation and metadata keywords:For the complete Validation specification, visit json-schema.org