{
  "schema_version": 2,
  "id": "develop/data-types/json/configuration",
  "title": "Configuration parameters",
  "url": "https://redis.io/docs/latest/develop/data-types/json/configuration/",
  "summary": "Configure how Redis JSON write commands handle missing paths",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-11-23T06:19:08-08:00",
  "page_type": "content",
  "content_hash": "a146d26700f87f6a8e53845294db8b2ae10ff5d10b9c534932d6f62415d3608b",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "Redis JSON has one configuration parameter, `json-auto-create-deep-paths`, added in Redis 8.12. It's a load-time parameter: you set it when Redis starts, and you can't change it with [`CONFIG SET`](https://redis.io/docs/latest/commands/config-set)."
    },
    {
      "id": "set-configuration-parameters",
      "title": "Set configuration parameters",
      "role": "content",
      "text": "Set the parameter in one of these ways:\n\n- Add it to your `redis.conf` file:\n\n  [code example]\n\n- Pass it on the command line when you start `redis-server`:\n\n  [code example]\n\nUse [`CONFIG GET`](https://redis.io/docs/latest/commands/config-get) to read the current value:\n\n[code example]\n\nSee also [Redis configuration](https://redis.io/docs/latest/operate/oss_and_stack/management/config)."
    },
    {
      "id": "redis-json-configuration-parameters",
      "title": "Redis JSON configuration parameters",
      "role": "content",
      "text": "| Parameter name | Run-time | Redis<br />Software | Redis<br />Cloud |\n| :------- | :------- | :------- | :------- |\n| [json-auto-create-deep-paths](#json-auto-create-deep-paths) | :white_large_square: |||"
    },
    {
      "id": "json-auto-create-deep-paths",
      "title": "json-auto-create-deep-paths",
      "role": "content",
      "text": "Added in v8.12.0.\n\nLets JSON write commands create missing objects along a path, instead of returning nil or an error. See [Auto-create missing paths](#auto-create-missing-paths).\n\nType: boolean (`yes` or `no`)\n\nDefault: `no`\n\n> [!WARNING]\n> Set the same value on a primary and all of its replicas. Redis replicates JSON write commands as they were sent, so a replica with a different value silently ends up with different data from its primary.\n> Use the same value when you replay or restore an append-only file (AOF), too. Commands recorded with auto-creation enabled might fail to recreate their data when it's disabled."
    },
    {
      "id": "auto-create-missing-paths",
      "title": "Auto-create missing paths",
      "role": "content",
      "text": "When `json-auto-create-deep-paths` is set to `yes`, a write command creates every missing object in its path and then writes at the end of the path. When it's set to `no`, the command writes only if everything except the last key in the path already exists.\n\nFor example, the following document has no `b` key. With auto-creation disabled, `JSON.SET doc $.a.b.c 5` returns `(nil)`. With it enabled, the command creates `b`:\n\n[code example]\n\nAuto-creation applies to [`JSON.SET`](https://redis.io/docs/latest/commands/json.set), [`JSON.MSET`](https://redis.io/docs/latest/commands/json.mset), [`JSON.MERGE`](https://redis.io/docs/latest/commands/json.merge), [`JSON.ARRAPPEND`](https://redis.io/docs/latest/commands/json.arrappend), [`JSON.ARRINSERT`](https://redis.io/docs/latest/commands/json.arrinsert), [`JSON.NUMINCRBY`](https://redis.io/docs/latest/commands/json.numincrby), and [`JSON.STRAPPEND`](https://redis.io/docs/latest/commands/json.strappend). It works with both JSONPath and legacy paths."
    },
    {
      "id": "set-and-merge",
      "title": "Set and merge",
      "role": "content",
      "text": "`JSON.SET`, `JSON.MSET`, and `JSON.MERGE` write their value at the end of the created path. These commands also create a key that doesn't exist, building the document from the path:\n\n[code example]\n\nWith `NX`, `JSON.SET` creates a missing path but doesn't overwrite an existing value. With `XX`, it never creates anything."
    },
    {
      "id": "append-insert-and-increment",
      "title": "Append, insert, and increment",
      "role": "content",
      "text": "`JSON.ARRAPPEND`, `JSON.ARRINSERT`, `JSON.NUMINCRBY`, and `JSON.STRAPPEND` create the missing path, give the new location a starting value, and then run as usual:\n\n| Command | Starting value |\n| :------ | :------------- |\n| `JSON.ARRAPPEND` | `[]` |\n| `JSON.ARRINSERT` | `[]` |\n| `JSON.NUMINCRBY` | `0` |\n| `JSON.STRAPPEND` | `\"\"` |\n\nThe reply is the same as if the starting value had already been there:\n\n[code example]\n\nThese commands follow some extra rules:\n\n- They don't create keys. On a key that doesn't exist, they return `ERR could not perform this operation on a key that doesn't exist`.\n- `JSON.ARRINSERT` creates a path only when `index` is `0`, the only valid index in an empty array. With any other index, it creates nothing and returns an empty array.\n- A starting value never replaces an existing value. If the path matches a value of the wrong type, the command replies as it does without auto-creation.\n- The command checks its value before it creates anything. If `JSON.NUMINCRBY` gets a value that isn't a number, or `JSON.STRAPPEND` gets one that isn't a JSON string, the command returns an error and leaves the document unchanged.\n\n[`JSON.NUMMULTBY`](https://redis.io/docs/latest/commands/json.nummultby) and [`JSON.NUMPOWBY`](https://redis.io/docs/latest/commands/json.numpowby) never create paths."
    },
    {
      "id": "paths-that-match-several-locations",
      "title": "Paths that match several locations",
      "role": "content",
      "text": "When a path matches several locations, such as `$['a','b'].c`, `$.*.n`, or `$..n`, the command creates the path where it's missing and updates it where it exists. Matches that aren't objects are skipped:\n\n[code example]"
    },
    {
      "id": "what-isnt-created",
      "title": "What isn't created",
      "role": "content",
      "text": "- **Array elements.** Only object keys are created. `JSON.SET doc '$.a.b[0]' 7` returns `ERR array index out of range`.\n- **New keys from complex paths.** Creating a key from a path that contains an array index or recursive descent, such as `$.a[0].b` or `$..a`, still returns `ERR new objects must be created at the root`.\n- **Paths through non-objects.** If a value that isn't an object is in the way, nothing is created there. For example, on `{\"a\":3}`, `JSON.SET doc $.a.b.c 5` returns `(nil)`.\n- **Paths beyond the depth limit.** If the created path would exceed the [nesting depth limit](https://redis.io/docs/latest/develop/data-types/json#limitation), the command returns `ERR recursion limit exceeded` and creates nothing. On an existing key, `JSON.MSET` returns nil instead."
    }
  ],
  "examples": [
    {
      "id": "set-configuration-parameters-ex0",
      "language": "plaintext",
      "code": "json-auto-create-deep-paths yes",
      "section_id": "set-configuration-parameters"
    },
    {
      "id": "set-configuration-parameters-ex1",
      "language": "plaintext",
      "code": "redis-server --json-auto-create-deep-paths yes",
      "section_id": "set-configuration-parameters"
    },
    {
      "id": "set-configuration-parameters-ex2",
      "language": "plaintext",
      "code": "redis> CONFIG GET json-auto-create-deep-paths\n1) \"json-auto-create-deep-paths\"\n2) \"yes\"",
      "section_id": "set-configuration-parameters"
    },
    {
      "id": "auto-create-missing-paths-ex0",
      "language": "plaintext",
      "code": "redis> JSON.SET doc $ '{\"a\":{\"keep\":1}}'\nOK\nredis> JSON.SET doc $.a.b.c 5\nOK\nredis> JSON.GET doc $\n\"[{\\\"a\\\":{\\\"keep\\\":1,\\\"b\\\":{\\\"c\\\":5}}}]\"",
      "section_id": "auto-create-missing-paths"
    },
    {
      "id": "set-and-merge-ex0",
      "language": "plaintext",
      "code": "redis> JSON.SET newdoc $.a.b.c 5\nOK\nredis> JSON.GET newdoc $\n\"[{\\\"a\\\":{\\\"b\\\":{\\\"c\\\":5}}}]\"\nredis> JSON.MSET newdoc2 $.a.b.c 5 newdoc2 $.d.e.f 6\nOK\nredis> JSON.GET newdoc2 $\n\"[{\\\"a\\\":{\\\"b\\\":{\\\"c\\\":5}},\\\"d\\\":{\\\"e\\\":{\\\"f\\\":6}}}]\"",
      "section_id": "set-and-merge"
    },
    {
      "id": "append-insert-and-increment-ex0",
      "language": "plaintext",
      "code": "redis> JSON.SET doc $ '{}'\nOK\nredis> JSON.ARRAPPEND doc $.a.tags '\"red\"' '\"blue\"'\n1) (integer) 2\nredis> JSON.NUMINCRBY doc $.stats.views 1\n\"[1]\"\nredis> JSON.STRAPPEND doc $.d.name '\"hi\"'\n1) (integer) 2\nredis> JSON.GET doc $\n\"[{\\\"a\\\":{\\\"tags\\\":[\\\"red\\\",\\\"blue\\\"]},\\\"stats\\\":{\\\"views\\\":1},\\\"d\\\":{\\\"name\\\":\\\"hi\\\"}}]\"",
      "section_id": "append-insert-and-increment"
    },
    {
      "id": "paths-that-match-several-locations-ex0",
      "language": "plaintext",
      "code": "redis> JSON.SET doc $ '{\"a\":{},\"b\":{\"c\":1},\"s\":\"str\"}'\nOK\nredis> JSON.SET doc $.*.c 7\nOK\nredis> JSON.GET doc $\n\"[{\\\"a\\\":{\\\"c\\\":7},\\\"b\\\":{\\\"c\\\":7},\\\"s\\\":\\\"str\\\"}]\"",
      "section_id": "paths-that-match-several-locations"
    }
  ]
}
