{
  "schema_version": 2,
  "id": "commands/lindex",
  "title": "LINDEX",
  "url": "https://redis.io/docs/latest/commands/lindex/",
  "summary": "Returns an element from a list by its index.",
  "since": "1.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": "64d82fbe1c75b11f31d7005718c8cff52615dd9cf1408a779e0b06a42728f047",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "Returns the element at index `index` in the list stored at `key`.\nThe index is zero-based, so `0` means the first element, `1` the second element\nand so on.\nNegative indices can be used to designate elements starting at the tail of the\nlist.\nHere, `-1` means the last element, `-2` means the penultimate and so forth.\n\nWhen the value at `key` is not a list, an error is returned."
    },
    {
      "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 list.\n\n</details>\n\n<details open><summary><code>index</code></summary>\n\nThe zero-based index of the element to return. Negative indexes count from the tail (`-1` is the last element).\n\n</details>"
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "redis> LPUSH mylist \"World\"\n(integer) 1\nredis> LPUSH mylist \"Hello\"\n(integer) 2\nredis> LINDEX mylist 0\n\"Hello\"\nredis> LINDEX mylist -1\n\"World\"\nredis> LINDEX mylist 3\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): when _index_ is out of range.\n* [Bulk string reply](../../develop/reference/protocol-spec#bulk-strings): the requested element.\n\n**RESP3:**\n\nOne of the following:\n* [Null reply](../../develop/reference/protocol-spec#nulls): when _index_ is out of range.\n* [Bulk string reply](../../develop/reference/protocol-spec#bulk-strings): the requested element."
    }
  ],
  "examples": []
}
