{
  "schema_version": 2,
  "id": "commands/zrevrangebylex",
  "title": "ZREVRANGEBYLEX",
  "url": "https://redis.io/docs/latest/commands/zrevrangebylex/",
  "summary": "Returns members in a sorted set within a lexicographical range in reverse order.",
  "since": "2.8.9",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-09-18T09:48:43+01:00",
  "page_type": "content",
  "content_hash": "3f56522eac04173ea339d718a749955e527790e61e62509041f5a1ed2e70db1a",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "When all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering, this command returns all the elements in the sorted set at `key` with a value between `max` and `min`.\n\nApart from the reversed ordering, `ZREVRANGEBYLEX` is similar to [`ZRANGEBYLEX`](https://redis.io/docs/latest/commands/zrangebylex)."
    },
    {
      "id": "required-arguments",
      "title": "Required arguments",
      "role": "content",
      "text": "<details open><summary><code>key</code></summary>\n\nThe name of the key that holds the sorted set.\n\n</details>\n\n<details open><summary><code>max</code></summary>\n\nThe maximum member, compared lexicographically. Prefix with `[` for an inclusive bound or `(` for an exclusive bound; use `+` for the highest possible value.\n\n</details>\n\n<details open><summary><code>min</code></summary>\n\nThe minimum member, compared lexicographically. Prefix with `[` for an inclusive bound or `(` for an exclusive bound; use `-` for the lowest possible value.\n\n</details>"
    },
    {
      "id": "optional-arguments",
      "title": "Optional arguments",
      "role": "parameters",
      "text": "<details open><summary><code>LIMIT offset count</code></summary>\n\nSkip `offset` matching members and return up to `count` of them. A negative `count` returns all remaining members.\n\n</details>"
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "redis> ZADD myzset 0 a 0 b 0 c 0 d 0 e 0 f 0 g\n(integer) 7\nredis> ZREVRANGEBYLEX myzset [c -\n1) \"c\"\n2) \"b\"\n3) \"a\"\nredis> ZREVRANGEBYLEX myzset (c -\n1) \"b\"\n2) \"a\"\nredis> ZREVRANGEBYLEX myzset (g [aaa\n1) \"f\"\n2) \"e\"\n3) \"d\"\n4) \"c\"\n5) \"b\""
    },
    {
      "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; Standard</span><br /><span title=\"Supported\"><nobr>&#x2705; Active-Active</nobr></span> | <span title=\"Supported\">&#x2705; Standard</span><br /><span title=\"Supported\"><nobr>&#x2705; Active-Active</nobr></span> | Deprecated as of Redis v6.2.0. |"
    },
    {
      "id": "return-information",
      "title": "Return information",
      "role": "returns",
      "text": "**RESP2:**\n\n[Array reply](../../develop/reference/protocol-spec#arrays): a list of members in the specified score range.\n\n**RESP3:**\n\n[Array reply](../../develop/reference/protocol-spec#arrays): List of the elements in the specified score range."
    }
  ],
  "examples": []
}
