{
  "id": "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`",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-04-09T10:29:34-04:00",
  "page_type": "content",
  "content_hash": "efa591b6e56a7234f03329d8e921bd4754117214f66ff718ee0b5f883ca15a67",
  "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\n \nAlready 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](): 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](): 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`]() | [`JSON.ARRINSERT`]()"
    },
    {
      "id": "related-topics",
      "title": "Related topics",
      "role": "related",
      "text": "* [RedisJSON]()\n* [Index and search JSON documents]()"
    }
  ],
  "examples": []
}
