{
  "id": "getrange",
  "title": "GETRANGE",
  "url": "https://redis.io/docs/latest/commands/getrange/",
  "summary": "Returns a substring of the string stored at a key.",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-07-02T11:31:07-05:00",
  "page_type": "content",
  "content_hash": "01ba3a48e3860f7cd5ece6cc35969eebdea23e7bf0bb4b653ce1a937f24e3775",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "Returns the substring of the string value stored at key, as determined by the start and end offsets. Both offsets are inclusive.\n\nYou can use negative offsets to count backward from the end of the string. For example, -1 is the last character, -2 is the penultimate character, and so on.\n\nThe function handles out of range requests by limiting the resulting range to\nthe actual length of the string."
    },
    {
      "id": "required-arguments",
      "title": "Required arguments",
      "role": "content",
      "text": "<details open><summary><code>key</code></summary>\n\nThe name of the key.\n\n</details>\n\n<details open><summary><code>start</code></summary>\n\nThe start offset, zero-based. A negative value counts from the end of the string.\n\n</details>\n\n<details open><summary><code>end</code></summary>\n\nThe end offset, zero-based and inclusive. A negative value counts from the end of the string.\n\n</details>"
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "SET mykey \"This is a string\"\nGETRANGE mykey 0 3\nGETRANGE mykey -3 -1\nGETRANGE mykey 0 -1\nGETRANGE mykey 10 100"
    },
    {
      "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[Bulk string reply](../../develop/reference/protocol-spec#bulk-strings): The substring of the string value stored at key, determined by the offsets start and end (both are inclusive).\n\n**RESP3:**\n\n[Bulk string reply](../../develop/reference/protocol-spec#bulk-strings): The substring of the string value stored at key, determined by the offsets start and end (both are inclusive)."
    }
  ],
  "examples": []
}
