$schema : URI

$schema

URI

This keyword is both used as a JSON Schema dialect identifier and as a reference to a JSON Schema which describes the set of valid schemas written for this particular dialect.

Value This keyword must be set to an absolute URI as defined by RFC 3986
Kind Identifier
Applies To Any
Base Dialect 2020-12
Changed In None
Introduced In Draft 3
Vocabulary Core
Specification https://json-schema.org/draft/2020-12/json-schema-core.html#section-8.1.1
Metaschema https://json-schema.org/draft/2020-12/meta/core
Official Tests None
Default Implementation or context dependent
Annotation None
Affected By None
Affects None
Also See

The $schema keyword serves to explicitly associate a schema or subschema with the JSON Schema dialect that defines it, where the dialect is the identifier of a meta-schema that defines the vocabularies in use and imposes syntactic constraints on its schema instances. If the $schema keyword is not declared, the schema inherits its context-specific or implementation-specific default dialect.

Strictly-compliant JSON Schema implementations will refuse to process a schema whose dialect cannot be unambiguously determined.

Note that the $schema keyword can occur multiple times in the same schema, and not only at the top-level. This is often the case when performing JSON Schema Bundling to inline externally referenced schemas that might be based on different dialects of JSON Schema.

A schema is considered syntactic valid if it successfully validates against its dialect meta-schema. You can validate a schema against its meta-schema using the jsonschema metaschema. For example:

$ jsonschema metaschema my-schema.json

Examples

A schema described by the JSON Schema 2020-12 official dialect Schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "string"
}
A valid schema without an explicitly declared dialect, prone to undefined behavior Schema
{
  "items": [ { "type": "number" } ]
}
A valid schema that mixes the 2020-12 and 2019-09 official dialects Schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "properties": {
    "price": { "type": "number" },
    "discount": {
      "$ref": "#/$defs/discount"
    }
  },
  "$defs": {
    "discount": {
      "$schema": "https://json-schema.org/draft/2019-09/schema",
      "type": "number"
    }
  }
}