{
  "schema_version": 2,
  "id": "commands/json.toggle",
  "title": "JSON.TOGGLE",
  "url": "https://redis.io/docs/latest/commands/json.toggle/",
  "summary": "Toggles a boolean value",
  "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": "58d1f472ece4f6025563411e696d7e783fb8537aac7b64f2a9bafdd79f2d7173",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "Toggle a Boolean value stored at `path`\n\n[Examples](#examples)"
    },
    {
      "id": "required-arguments",
      "title": "Required arguments",
      "role": "content",
      "text": "<details open><summary><code>key</code></summary> \n\nis key to modify.\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 `$`. \n\n</details>"
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "<details open>\n<summary><b>Toggle a Boolean value stored at <code>path</code></b></summary>\n\nCreate a JSON document.\n\n\nredis> JSON.SET doc $ '{\"bool\": true}'\nOK\n\n\nToggle the Boolean value.\n\n\nredis> JSON.TOGGLE doc $.bool\n1) (integer) 0\n\n\nGet the updated document.\n\n\nredis> JSON.GET doc $\n\"[{\\\"bool\\\":false}]\"\n\n\nToggle the Boolean value.\n\n\nredis> JSON.TOGGLE doc $.bool\n1) (integer) 1\n\n\nGet the updated document.\n\n\nredis> JSON.GET doc $\n\"[{\\\"bool\\\":true}]\"\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\nWith `$`-based path argument: [Array reply](https://redis.io/docs/latest/develop/reference/protocol-spec#arrays) of [integer replies](https://redis.io/docs/latest/develop/reference/protocol-spec#integers) or [null replies](https://redis.io/docs/latest/develop/reference/protocol-spec#nulls), where each element is the new value (`0` if `false` or `1` if `true`), or `null` if the matching value is not Boolean.\n\nWith `.`-based path argument: [Integer reply](https://redis.io/docs/latest/develop/reference/protocol-spec#integers) representing the new value (`0` if `false` or `1` if `true`), or [null reply](https://redis.io/docs/latest/develop/reference/protocol-spec#nulls) if the matching value is not Boolean.\n\n**RESP3:**\n\nWith `$`-based path argument (default): [Array reply](https://redis.io/docs/latest/develop/reference/protocol-spec#arrays) of [integer replies](https://redis.io/docs/latest/develop/reference/protocol-spec#integers) or [null replies](https://redis.io/docs/latest/develop/reference/protocol-spec#nulls), where each element is the new value (`0` if `false` or `1` if `true`), or `null` if the matching value is not Boolean.\n\nWith `.`-based path argument: [Integer reply](https://redis.io/docs/latest/develop/reference/protocol-spec#integers) representing the new value (`0` if `false` or `1` if `true`), or [null reply](https://redis.io/docs/latest/develop/reference/protocol-spec#nulls) if the matching value is not Boolean."
    },
    {
      "id": "see-also",
      "title": "See also",
      "role": "related",
      "text": "[`JSON.SET`](https://redis.io/docs/latest/commands/json.set) | [`JSON.GET`](https://redis.io/docs/latest/commands/json.get)"
    },
    {
      "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": []
}
