{
  "schema_version": 2,
  "id": "commands/zrank",
  "title": "ZRANK",
  "url": "https://redis.io/docs/latest/commands/zrank/",
  "summary": "Returns the index of a member in a sorted set ordered by ascending scores.",
  "since": "2.0.0",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-09-18T09:48:43+01:00",
  "page_type": "content",
  "content_hash": "61e8b4a3ab89575ccc8f01dae7096f7240f20b3e599e956af0d99e2ed880ef1a",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "Returns the rank of `member` in the sorted set stored at `key`, with the scores\nordered from low to high.\nThe rank (or index) is 0-based, which means that the member with the lowest\nscore has rank `0`.\n\nThe optional `WITHSCORE` argument supplements the command's reply with the score of the element returned.\n\nUse [`ZREVRANK`](https://redis.io/docs/latest/commands/zrevrank) to get the rank of an element with the scores ordered from high\nto low."
    },
    {
      "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>member</code></summary>\n\nThe member whose rank to return.\n\n</details>"
    },
    {
      "id": "optional-arguments",
      "title": "Optional arguments",
      "role": "parameters",
      "text": "<details open><summary><code>WITHSCORE</code></summary>\n\nAlso return the member's score along with its rank.\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> ZRANK myzset \"three\"\n(integer) 2\nredis> ZRANK myzset \"four\"\n(nil)\nredis> ZRANK myzset \"three\" WITHSCORE\n1) (integer) 2\n2) \"3\"\nredis> ZRANK myzset \"four\" WITHSCORE\n(nil)"
    },
    {
      "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\nOne of the following:\n* [Nil reply](../../develop/reference/protocol-spec#bulk-strings): if the key does not exist or the member does not exist in the sorted set.\n* [Integer reply](../../develop/reference/protocol-spec#integers): the rank of the member when _WITHSCORE_ is not used.\n* [Array reply](../../develop/reference/protocol-spec#arrays): the rank and score of the member when _WITHSCORE_ is used.\n\n**RESP3:**\n\nOne of the following:\n* [Null reply](../../develop/reference/protocol-spec#nulls): if the key does not exist or the member does not exist in the sorted set.\n* [Integer reply](../../develop/reference/protocol-spec#integers): the rank of the member when _WITHSCORE_ is not used.\n* [Array reply](../../develop/reference/protocol-spec#arrays): the rank and score of the member when _WITHSCORE_ is used."
    }
  ],
  "examples": []
}
