{
  "schema_version": 2,
  "id": "commands/zremrangebyrank",
  "title": "ZREMRANGEBYRANK",
  "url": "https://redis.io/docs/latest/commands/zremrangebyrank/",
  "summary": "Removes members in a sorted set within a range of indexes. Deletes the sorted set if all members were removed.",
  "since": "2.0.0",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-07-24T11:07:00+02:00",
  "page_type": "content",
  "content_hash": "bf6dfe6324d7d73f9042550e04f5c396212fcbc2fc276532600e244eba1c0a38",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "Removes all elements in the sorted set stored at `key` with rank between `start`\nand `stop`.\nBoth `start` and `stop` are `0` -based indexes with `0` being the element with\nthe lowest score.\nThese indexes can be negative numbers, where they indicate offsets starting at\nthe element with the highest score.\nFor example: `-1` is the element with the highest score, `-2` the element with\nthe second highest score and so forth."
    },
    {
      "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>start</code></summary>\n\nThe start index, zero-based. Negative values count from the end of the sorted set (`-1` is the member with the highest score).\n\n</details>\n\n<details open><summary><code>stop</code></summary>\n\nThe stop index, zero-based and inclusive. Negative values count from the end of the sorted set.\n\n</details>"
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "redis> ZADD myzset 1 \"one\"\n(integer) 1\nredis> ZADD myzset 2 \"two\"\n(integer) 1\nredis> ZADD myzset 3 \"three\"\n(integer) 1\nredis> ZREMRANGEBYRANK myzset 0 1\n(integer) 2\nredis> ZRANGE myzset 0 -1 WITHSCORES\n1) \"three\"\n2) \"3\""
    },
    {
      "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> |  |"
    },
    {
      "id": "return-information",
      "title": "Return information",
      "role": "returns",
      "text": "**RESP2:**\n\n[Integer reply](../../develop/reference/protocol-spec#integers): the number of members removed.\n\n**RESP3:**\n\n[Integer reply](../../develop/reference/protocol-spec#integers): Number of members removed."
    }
  ],
  "examples": []
}
