2020-12 Dialect

JSON Schema 2020-12 is a JSON media type for defining the structure of JSON data. JSON Schema is intended to define validation, documentation, hyperlink navigation, and interaction control of JSON data.

Using this dialect

To make use of this dialect, declare your schemas to have the dialect metaschema using the $schema keyword. For example:

{
  "$schema": "https://json-schema.org/draft/2020-12/schema" 
}

Citing this dialect

The recommended way to cite the JSON Schema 2020-12 dialect using BibTex is as follows:

@techreport{json-schema-2020-12,
  title = { JSON Schema: A Media Type for Describing JSON Documents },
  author = { Wright, Austin and Andrews, Henry and Hutton, Ben and Dennis, Greg },
  organization = { JSON Schema },
  year = { 2020 },
  url = { https://json-schema.org/draft/2020-12/json-schema-core.html }
}

Vocabularies

A curated set of vocabularies defined for this JSON Schema dialect.

Core Official Included By Default

A mandatory vocabulary that defines keywords that are either required in order to process any schema or meta-schema, including those split across multiple documents, or exist to reserve keywords for purposes that require guaranteed interoperability. Read more about this vocabulary.

Keyword Kind Instance Summary
$schema Identifier Any 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.
$id Identifier Any This keyword declares an identifier for the schema resource.
$ref Applicator Any This keyword is used to reference a statically identified schema.
$defs Reserved Location Any This keyword is used in meta-schemas to identify the required and optional vocabularies available for use in schemas described by that meta-schema.
$comment Reserved Location Any This keyword reserves a location for comments from schema authors to readers or maintainers of the schema.
$dynamicAnchor Identifier Any This keyword is used to create plain name fragments that are not tied to any particular structural location for referencing purposes, which are taken into consideration for dynamic referencing.
$dynamicRef Applicator Any This keyword is used to reference an identified schema, deferring the full resolution until runtime, at which point it is resolved each time it is encountered while evaluating an instance.
$anchor Identifier Any This keyword is used to create plain name fragments that are not tied to any particular structural location for referencing purposes, which are taken into consideration for static referencing.
$vocabulary Identifier Any This keyword is used in meta-schemas to identify the required and optional vocabularies available for use in schemas described by that meta-schema.

Applicator Official Included By Default

A vocabulary that defines applicator keywords that are recommended for use as the basis of other vocabularies. Read more about this vocabulary.

Keyword Kind Instance Summary
oneOf Applicator Any An instance validates successfully against this keyword if it validates successfully against exactly one schema defined by this keyword’s value.
allOf Applicator Any An instance validates successfully against this keyword if it validates successfully against all schemas defined by this keyword’s value.
anyOf Applicator Any An instance validates successfully against this keyword if it validates successfully against at least one schema defined by this keyword’s value.
if Applicator Any This keyword declares a condition based on the validation result of the given schema.
then Applicator Any When if is present, and the instance successfully validates against its subschema, then validation succeeds against this keyword if the instance also successfully validates against this keyword’s subschema.
else Applicator Any When if is present, and the instance fails to validate against its subschema, then validation succeeds against this keyword if the instance successfully validates against this keyword’s subschema.
not Applicator Any An instance is valid against this keyword if it fails to validate successfully against the schema defined by this keyword.
properties Applicator Annotation Object Validation succeeds if, for each name that appears in both the instance and as a name within this keyword’s value, the child instance for that name successfully validates against the corresponding schema.
patternProperties Applicator Annotation Object Validation succeeds if, for each instance name that matches any regular expressions that appear as a property name in this keyword’s value, the child instance for that name successfully validates against each schema that corresponds to a matching regular expression.
additionalProperties Applicator Annotation Object Validation succeeds if the schema validates against each value not matched by other object applicators in this vocabulary.
dependentSchemas Applicator Object This keyword specifies subschemas that are evaluated if the instance is an object and contains a certain property.
propertyNames Applicator Object Validation succeeds if the schema validates against every property name in the instance.
prefixItems Applicator Annotation Array Validation succeeds if each element of the instance validates against the schema at the same position, if any.
contains Applicator Annotation Array Validation succeeds if the instance contains an element that validates against this schema.
items Applicator Annotation Array Validation succeeds if each element of the instance not covered by prefixItems validates against this schema.

Validation Official Included By Default

A vocabulary that defines keywords that impose requirements for successful validation of an instance. Read more about this vocabulary.

Keyword Kind Instance Summary
type Assertion Any Validation succeeds if the type of the instance matches the type represented by the given type, or matches at least one of the given types.
enum Assertion Any Validation succeeds if the instance is equal to one of the elements in this keyword’s array value.
const Assertion Any Validation succeeds if the instance is equal to this keyword’s value.
minLength Assertion String A string instance is valid against this keyword if its length is greater than, or equal to, the value of this keyword.
maxLength Assertion String A string instance is valid against this keyword if its length is less than, or equal to, the value of this keyword.
pattern Assertion String A string instance is considered valid if the regular expression matches the instance successfully.
maximum Assertion Number Validation succeeds if the numeric instance is less than or equal to the given number.
exclusiveMinimum Assertion Number Validation succeeds if the numeric instance is greater than the given number.
multipleOf Assertion Number A numeric instance is valid only if division by this keyword’s value results in an integer.
exclusiveMaximum Assertion Number Validation succeeds if the numeric instance is less than the given number.
minimum Assertion Number Validation succeeds if the numeric instance is greater than or equal to the given number.
dependentRequired Assertion Object Validation succeeds if, for each name that appears in both the instance and as a name within this keyword’s value, every item in the corresponding array is also the name of a property in the instance.
minProperties Assertion Object An object instance is valid if its number of properties is greater than, or equal to, the value of this keyword.
maxProperties Assertion Object An object instance is valid if its number of properties is less than, or equal to, the value of this keyword.
required Assertion Object An object instance is valid against this keyword if every item in the array is the name of a property in the instance.
minItems Assertion Array An array instance is valid if its size is greater than, or equal to, the value of this keyword.
maxItems Assertion Array An array instance is valid if its size is less than, or equal to, the value of this keyword.
minContains Assertion Array The number of times that the contains keyword (if set) successfully validates against the instance must be greater than or equal to the given integer.
maxContains Assertion Array The number of times that the contains keyword (if set) successfully validates against the instance must be less than or equal to the given integer.
uniqueItems Assertion Array If this keyword is set to the boolean value true, the instance validates successfully if all of its elements are unique.

Meta Data Official Included By Default

A vocabulary to defines general-purpose annotation keywords that provide commonly used information for documentation and user interface display purposes. Read more about this vocabulary.

Keyword Kind Instance Summary
title Annotation Any A preferably short description about the purpose of the instance described by the schema.
description Annotation Any An explanation about the purpose of the instance described by the schema.
default Annotation Any This keyword can be used to supply a default JSON value associated with a particular schema.
deprecated Annotation Any This keyword indicates that applications should refrain from using the declared property.
examples Annotation Any This keyword is used to provide sample JSON values associated with a particular schema, for the purpose of illustrating usage.
readOnly Annotation Any This keyword indicates that the value of the instance is managed exclusively by the owning authority, and attempts by an application to modify the value of this property are expected to be ignored or rejected by that owning authority.
writeOnly Annotation Any This keyword indicates that the value is never present when the instance is retrieved from the owning authority.

Format Annotation Official Included By Default

A vocabulary to defines semantic information about string-encoded values. Read more about this vocabulary.

Keyword Kind Instance Summary
format Annotation String Define semantic information about a string instance.

Unevaluated Official Included By Default

A mandatory vocabulary that defines keywords that apply subschemas to array items or object properties that have not been successfully evaluated against any dynamic-scope subschema of any adjacent keywords. Read more about this vocabulary.

Keyword Kind Instance Summary
unevaluatedItems Applicator Annotation Array Validates array elements that did not successfully validate against other standard array applicators.
unevaluatedProperties Applicator Annotation Object Validates object properties that did not successfully validate against other standard object applicators.

Content Official Included By Default

A vocabulary that defines keywords for annotating instances that contain non-JSON data encoded in JSON strings. Read more about this vocabulary.

Keyword Kind Instance Summary
contentEncoding Annotation String The string instance should be interpreted as encoded binary data and decoded using the encoding named by this property.
contentMediaType Annotation String This keyword declares the media type of the string instance.
contentSchema Annotation String This keyword declares a schema which describes the structure of the string.

Format Assertion Official

A vocabulary to defines and asserts semantic information about string-encoded values. Read more about this vocabulary.

Keyword Kind Instance Summary
format Annotation Assertion String Define and assert semantic information about a string instance.