$dynamicAnchor : String



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.

Value This keyword must be set to a string starting with a letter and containing letters, digits, hyphens, underscores, colons, or periods
Kind Identifier
Applies To Any
Dialect 2020-12
Changed In None
Introduced In 2020-12
Vocabulary Core
Specification https://json-schema.org/draft/2020-12/json-schema-core.html#section-8.2.2
Metaschema https://json-schema.org/draft/2020-12/meta/core
Official Tests draft2020-12/dynamicRef.json
Default None
Annotation None
Affected By None
Also See

The $dynamicAnchor keyword allows the creation of plain name fragments that are not tied to a particular structural location within a schema. This is particularly useful for making subschemas reusable and relocatable without needing to update JSON Pointer references. Unlike $anchor, $dynamicAnchor indicates an extension point when used with the $dynamicRef keyword, facilitating the extension of recursive schemas without imposing specific semantics on that extension. Without $dynamicRef, $dynamicAnchor behaves the same as $anchor.


A '$dynamicRef' resolves to the first '$dynamicAnchor' still in scope that is encountered when the schema is evaluated Schema
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://example.com/root",
  "$ref": "list",
  "$defs": {
    "foo": {
      "$dynamicAnchor": "items",
      "type": "string"
    "list": {
      "$id": "list",
      "type": "array",
      "items": {
        "$dynamicRef": "#items"
      "$defs": {
        "items": {
          "$dynamicAnchor": "items",
          "type": "number"
Valid An array of strings is valid Instance
[ "foo", "bar" ]
Invalid An array containing non-strings is invalid Instance
[ "foo", 42 ]

Note: A $dynamicRef referencing a $dynamicAnchor within the same schema resource functions similarly to a standard $ref referencing an $anchor. Similarly, a $dynamicRef referencing an $anchor within the same schema resource behaves like a typical $ref referencing an $anchor. Likewise, a $ref targeting a $dynamicAnchor within the same schema resource behaves like a regular $ref targeting an $anchor.