$schema keyword is both used as a JSON Schema dialect identifier and as the identifier of a resource which is itself a JSON Schema, which describes the set of valid schemas written for this particular dialect.
Syntax
An IRI (containing a scheme) that identifies the JSON Schema dialect. This IRI MUST be normalized.
Purpose
The$schema keyword serves two critical functions:
- Dialect Identification: Specifies which version and dialect of JSON Schema the schema document uses
- Meta-Schema Reference: Points to a JSON Schema that validates the syntax of schemas written in this dialect
$schema keyword.
Usage
Placement
The$schema keyword:
- SHOULD be used in the document root schema object
- MAY be used in root schema objects of embedded schema resources
- MUST NOT appear in subschemas that are not also root objects of schema resources
Value Format
The value MUST be:- A valid IRI containing a scheme (e.g.,
https://) - Normalized according to IRI normalization rules
- Typically an absolute IRI pointing to a meta-schema
Examples
Basic Usage
With Embedded Resources
$defs/customSchema uses a different dialect than the main schema.
Dialect Determination
When evaluation encounters a new schema resource, implementations determine the dialect using this priority:- The
$schemakeyword - Process the schema according to the declared dialect - Parent schema dialect - Embedded resources without
$schemause the parent’s dialect - External context - Media type parameters or document-level defaults
- User configuration - Implementation-specific dialect configuration
Related Keywords
$id- Identifies the schema resource$vocabulary- Declares required and optional vocabularies (meta-schema feature)