JSON Schema 2020-12 Keyword Reference

Core validation and composition keywords in JSON Schema 2020-12, with compact examples and traps.

  • JSON6,798 B
  • YAML4,833 B · −29%
  • TOON3,848 B · −43%

Core validation and composition keywords in JSON Schema 2020-12, with compact examples and traps. Each row includes a practical application and a failure to check before using it.

Use it when

  • Validate a dataset before sending it to an agent.
  • Design a small contract for API input or a downloaded table.

Watch out for

  • These examples target draft 2020-12.
  • Validation does not establish factual correctness.

The data

KeywordExamplePurposePitfall
type{"type":"string"}Constrain the JSON value type.A numeric-looking string is still a string.
properties{"properties":{"name":{"type":"string"}}}Validate named object properties.Listed properties are optional unless required says otherwise.
required{"required":["name"]}Require object property presence.Presence does not exclude an empty string or null by itself.
additionalProperties{"additionalProperties":false}Restrict properties not covered by properties or patternProperties.Composition can require unevaluatedProperties instead.
unevaluatedProperties{"unevaluatedProperties":false}Restrict properties left unevaluated across applicable subschemas.Use a validator with the correct draft support.
items{"items":{"type":"integer"}}Validate array items with one schema.It does not require a nonempty array.
prefixItems{"prefixItems":[{"type":"string"},{"type":"integer"}]}Validate positional array elements.Length constraints are separate.
minItems{"minItems":1}Require a minimum array length.It does not constrain each item’s type.
enum{"enum":["json","yaml","toon"]}Accept one of an explicit set of values.Values are case sensitive.
const{"const":"ready"}Accept one exact JSON value.It can constrain more than strings.
minimum{"minimum":0}Set an inclusive numeric lower bound.Strings are not numeric values.
pattern{"pattern":"^[A-Z]{2}$"}Validate a string with a regular expression.Patterns are not anchored automatically.
allOf{"allOf":[{"type":"integer"},{"minimum":0}]}Require every subschema to pass.It is logical intersection, not object inheritance.
anyOf{"anyOf":[{"type":"string"},{"type":"number"}]}Require at least one passing subschema.Multiple matches are allowed.
oneOf{"oneOf":[{"const":"a"},{"const":"b"}]}Require exactly one passing subschema.Overlapping alternatives cause rejection.
format{"format":"date-time"}Annotate a string with a named semantic format.Assertion behavior depends on the dialect and validator.

Fields

The shape of this dataset, read from the data itself: every column, its type and a real value. Agents can use this to plan a query without fetching the whole document.

SectionFieldTypeExample
datakeywordstringtype
dataexamplestring{"type":"string"}
datapurposestringConstrain the JSON value type.
datapitfallstringA numeric-looking string is still a string.

Fetch the same bytes

The static files contain the same reference rows as the API, with no API rate limit. Live metadata, such as view counts, may differ. Use the API for content negotiation; use the static files for a cacheable snapshot.

curl "https://yjtoon.com/api/dataset/json-schema-keywords?format=toon"
const res = await fetch(
  "https://yjtoon.com/static-data/dataset/json-schema-keywords.toon"
);
const toon = await res.text();

Rate limit: 120 requests per minute per IP, no key and no signup. API reference →

Sources and editorial notes

Original editorial reference notes by YJTOON, informed by the linked primary documentation. External specifications retain their own licenses.

Editorial review: . Source documents keep their own licenses.

Topics

  • web-technologies
  • json schema keywords
  • reference
  • engineering

Search the library

Search by a topic, title, or keyword.

Start with a collection

Browse all 205 datasets