{
  "schema_version": 2,
  "id": "commands/json.clear",
  "title": "JSON.CLEAR",
  "url": "https://redis.io/docs/latest/commands/json.clear/",
  "summary": "Clears all values from an array or an object and sets numeric values to `0`",
  "since": "2.0.0",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-09-18T09:47:58+01:00",
  "page_type": "content",
  "content_hash": "3f41cd5d53b430d593046da06a2b050e148e9524fd6b51017016ad7da7242bab",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "Clear container values (arrays/objects) and set numeric values to `0`\n\n[Examples](#examples)"
    },
    {
      "id": "required-arguments",
      "title": "Required arguments",
      "role": "content",
      "text": "<details open><summary><code>key</code></summary> \n\nis key to parse.\n</details>"
    },
    {
      "id": "optional-arguments",
      "title": "Optional arguments",
      "role": "parameters",
      "text": "<details open><summary><code>path</code></summary> \n\nis JSONPath to specify. Default is root `$`. Nonexisting paths are ignored.\n</details>\n\n> [!NOTE]\n>  \n> Already cleared values are ignored for empty containers and zero numbers."
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "<details open>\n<summary><b>Clear container values and set numeric values to <code>0</code></b></summary>\n\nCreate a JSON document.\n\n\nredis> JSON.SET doc $ '{\"obj\":{\"a\":1, \"b\":2}, \"arr\":[1,2,3], \"str\": \"foo\", \"bool\": true, \"int\": 42, \"float\": 3.14}'\nOK\n\n\nClear all container values. This returns the number of objects with cleared values.\n\n\nredis> JSON.CLEAR doc $.*\n(integer) 4\n\n\nGet the updated document. Note that numeric values have been set to `0`.\n\n\nredis> JSON.GET doc $\n\"[{\\\"obj\\\":{},\\\"arr\\\":[],\\\"str\\\":\\\"foo\\\",\\\"bool\\\":true,\\\"int\\\":0,\\\"float\\\":0}]\"\n\n</details>"
    },
    {
      "id": "redis-software-and-redis-cloud-compatibility",
      "title": "Redis Software and Redis Cloud compatibility",
      "role": "content",
      "text": "| Redis<br />Software | Redis<br />Cloud | <span style=\"min-width: 9em; display: table-cell\">Notes</span> |\n|:----------------------|:-----------------|:------|\n| <span title=\"Supported\">&#x2705; Supported</span><br /> | <span title=\"Supported\">&#x2705; Flexible & Annual</span><br /><span title=\"Supported\">&#x2705; Free & Fixed</nobr></span> |  |"
    },
    {
      "id": "return-information",
      "title": "Return information",
      "role": "returns",
      "text": "**RESP2:**\n\n[Integer reply](https://redis.io/docs/latest/develop/reference/protocol-spec#integers): the number of matching JSON arrays and objects cleared plus the number of matching JSON numerical values zeroed.\n\n**RESP3:**\n\n[Integer reply](https://redis.io/docs/latest/develop/reference/protocol-spec#integers): the number of matching JSON arrays and objects cleared plus the number of matching JSON numerical values zeroed."
    },
    {
      "id": "see-also",
      "title": "See also",
      "role": "related",
      "text": "[`JSON.ARRINDEX`](https://redis.io/docs/latest/commands/json.arrindex) | [`JSON.ARRINSERT`](https://redis.io/docs/latest/commands/json.arrinsert)"
    },
    {
      "id": "related-topics",
      "title": "Related topics",
      "role": "related",
      "text": "* [RedisJSON](https://redis.io/docs/latest/develop/data-types/json)\n* [Index and search JSON documents](https://redis.io/docs/latest/develop/ai/search-and-query/indexing)"
    }
  ],
  "examples": []
}
