{
  "schema_version": 2,
  "id": "commands/lrange",
  "title": "LRANGE",
  "url": "https://redis.io/docs/latest/commands/lrange/",
  "summary": "Returns a range of elements from a list.",
  "since": "1.0.0",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-07-08T12:05:04+02:00",
  "page_type": "content",
  "content_hash": "0969ae33ee8221a49fe08076883eb81f40714cea01c46e7d4802ce38ab03f8f5",
  "sections": [
    {
      "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>start</code></summary>\n\nThe zero-based start index. Negative indexes count from the tail.\n\n</details>\n\n<details open><summary><code>stop</code></summary>\n\nThe zero-based stop index (inclusive). Negative indexes count from the tail.\n\n</details>"
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "Foundational: Retrieve a range of elements from a list using LRANGE with start and stop indexes (supports negative indexes, inclusive range)\n\n**Difficulty:** Beginner\n\n**Commands:** RPUSH, LRANGE\n\n**Complexity:**\n- RPUSH: O(1)\n- LRANGE: O(S+N)\n\n**Available in:** Redis CLI, C#, Go, Java (Asynchronous - Lettuce), Java (Reactive - Lettuce), Java (Synchronous - Jedis), JavaScript (Node.js), JavaScript (Node.js), PHP, Python, Ruby, Rust (Asynchronous), Rust (Synchronous)\n\n##### Redis CLI\n\n[code example]\n\n##### C#\n\n[code example]\n\n##### Go\n\n[code example]\n\n##### Java (Asynchronous - Lettuce)\n\n[code example]\n\n##### Java (Reactive - Lettuce)\n\n[code example]\n\n##### Java (Synchronous - Jedis)\n\n[code example]\n\n##### JavaScript (Node.js)\n\n[code example]\n\n##### JavaScript (Node.js)\n\n[code example]\n\n##### JavaScript (Node.js)\n\n[code example]\n\n##### JavaScript (Node.js)\n\n[code example]\n\n##### PHP\n\n[code example]\n\n##### Python\n\n[code example]\n\n##### Ruby\n\n[code example]\n\n##### Rust (Asynchronous)\n\n[code example]\n\n##### Rust (Synchronous)\n\n[code example]"
    },
    {
      "id": "details",
      "title": "Details",
      "role": "content",
      "text": ""
    },
    {
      "id": "consistency-with-range-functions-in-various-programming-languages",
      "title": "Consistency with range functions in various programming languages",
      "role": "content",
      "text": "Note that if you have a list of numbers from 0 to 100, `LRANGE list 0 10` will\nreturn 11 elements, that is, the rightmost item is included.\nThis may or may not be consistent with the behavior of range-related functions\nin your programming language of choice (think Ruby's `Range.new`, `Array#slice`\nor Python's `range()` function)."
    },
    {
      "id": "out-of-range-indexes",
      "title": "Out-of-range indexes",
      "role": "content",
      "text": "Out of range indexes will not produce an error.\nIf `start` is larger than the end of the list, an empty list is returned.\nIf `stop` is larger than the actual end of the list, Redis will treat it like\nthe last element of the list."
    },
    {
      "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[Array reply](../../develop/reference/protocol-spec#arrays): a list of elements in the specified range, or an empty array if the key doesn't exist.\n\n**RESP3:**\n\n[Array reply](../../develop/reference/protocol-spec#arrays): a list of elements in the specified range, or an empty array if the key doesn't exist."
    }
  ],
  "examples": [
    {
      "id": "examples-ex0",
      "language": "plaintext",
      "code": "redis> RPUSH mylist \"one\"\n(integer) 1\nredis> RPUSH mylist \"two\"\n(integer) 2\nredis> RPUSH mylist \"three\"\n(integer) 3\nredis> LRANGE mylist 0 0\n1) \"one\"\nredis> LRANGE mylist -3 2\n1) \"one\"\n2) \"two\"\n3) \"three\"\nredis> LRANGE mylist -100 100\n1) \"one\"\n2) \"two\"\n3) \"three\"\nredis> LRANGE mylist 5 10\n(empty array)",
      "section_id": "examples"
    },
    {
      "id": "examples-ex1",
      "language": "csharp",
      "code": "long lRangeResult1 = db.ListRightPush(\"mylist\", [\"one\", \"two\", \"three\"]);\n        Console.WriteLine(lRangeResult1); // >>> 3\n\n        RedisValue[] lRangeResult2 = db.ListRange(\"mylist\", 0, 0);\n        Console.WriteLine($\"[{string.Join(\", \", lRangeResult2)}]\");\n        // >>> [one]\n\n        RedisValue[] lRangeResult3 = db.ListRange(\"mylist\", -3, 2);\n        Console.WriteLine($\"[{string.Join(\", \", lRangeResult3)}]\");\n        // >>> [one, two, three]\n\n        RedisValue[] lRangeResult4 = db.ListRange(\"mylist\", -100, 100);\n        Console.WriteLine($\"[{string.Join(\", \", lRangeResult4)}]\");\n        // >>> [one, two, three]\n\n        RedisValue[] lRangeResult5 = db.ListRange(\"mylist\", 5, 10);\n        Console.WriteLine($\"[{string.Join(\", \", lRangeResult5)}]\");\n        // >>> []",
      "section_id": "examples"
    },
    {
      "id": "examples-ex2",
      "language": "go",
      "code": "RPushResult, err := rdb.RPush(ctx, \"mylist\",\n\t\t\"one\", \"two\", \"three\",\n\t).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(RPushResult) // >>> 3\n\n\tlRangeResult1, err := rdb.LRange(ctx, \"mylist\", 0, 0).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(lRangeResult1) // >>> [one]\n\n\tlRangeResult2, err := rdb.LRange(ctx, \"mylist\", -3, 2).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(lRangeResult2) // >>> [one two three]\n\n\tlRangeResult3, err := rdb.LRange(ctx, \"mylist\", -100, 100).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(lRangeResult3) // >>> [one two three]\n\n\tlRangeResult4, err := rdb.LRange(ctx, \"mylist\", 5, 10).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(lRangeResult4) // >>> []",
      "section_id": "examples"
    },
    {
      "id": "examples-ex3",
      "language": "java",
      "code": "CompletableFuture<Void> lrange = asyncCommands.rpush(\"mylist\", \"one\").thenCompose(res4 -> {\n                System.out.println(res4); // >>> 1\n\n                return asyncCommands.rpush(\"mylist\", \"two\");\n            }).thenCompose(res5 -> {\n                System.out.println(res5); // >>> 2\n\n                return asyncCommands.rpush(\"mylist\", \"three\");\n            }).thenCompose(res6 -> {\n                System.out.println(res6); // >>> 3\n\n                return asyncCommands.lrange(\"mylist\", 0, 0);\n            }).thenCompose(res7 -> {\n                System.out.println(res7); // >>> [one]\n\n                return asyncCommands.lrange(\"mylist\", -3, 2);\n            }).thenCompose(res8 -> {\n                System.out.println(res8); // >>> [one, two, three]\n\n                return asyncCommands.lrange(\"mylist\", -100, 100);\n            }).thenCompose(res9 -> {\n                System.out.println(res9); // >>> [one, two, three]\n\n                return asyncCommands.lrange(\"mylist\", 5, 10);\n            })\n                    .thenAccept(res10 -> System.out.println(res10)) // >>> []\n                    .toCompletableFuture();",
      "section_id": "examples"
    },
    {
      "id": "examples-ex4",
      "language": "java",
      "code": "Mono<Void> lrange = reactiveCommands.rpush(\"mylist\", \"one\").doOnNext(res4 -> {\n                System.out.println(res4); // >>> 1\n            }).flatMap(res4 -> reactiveCommands.rpush(\"mylist\", \"two\")).doOnNext(res5 -> {\n                System.out.println(res5); // >>> 2\n            }).flatMap(res5 -> reactiveCommands.rpush(\"mylist\", \"three\")).doOnNext(res6 -> {\n                System.out.println(res6); // >>> 3\n            }).flatMap(res6 -> reactiveCommands.lrange(\"mylist\", 0, 0).collectList()).doOnNext(res7 -> {\n                System.out.println(res7); // >>> [one]\n            }).flatMap(res7 -> reactiveCommands.lrange(\"mylist\", -3, 2).collectList()).doOnNext(res8 -> {\n                System.out.println(res8); // >>> [one, two, three]\n            }).flatMap(res8 -> reactiveCommands.lrange(\"mylist\", -100, 100).collectList()).doOnNext(res9 -> {\n                System.out.println(res9); // >>> [one, two, three]\n            }).flatMap(res9 -> reactiveCommands.lrange(\"mylist\", 5, 10).collectList()).doOnNext(res10 -> {\n                System.out.println(res10); // >>> []\n            }).then();",
      "section_id": "examples"
    },
    {
      "id": "examples-ex5",
      "language": "java",
      "code": "long lRangeResult1 = jedis.rpush(\"mylist\", \"one\", \"two\", \"three\");\n        System.out.println(lRangeResult1); // >>> 3\n\n        List<String> lRangeResult2 = jedis.lrange(\"mylist\", 0, 0);\n        System.out.println(lRangeResult2); // >>> [one]\n\n        List<String> lRangeResult3 = jedis.lrange(\"mylist\", -3, 2);\n        System.out.println(lRangeResult3); // >>> [one, two, three]\n\n        List<String> lRangeResult4 = jedis.lrange(\"mylist\", -100, 100);\n        System.out.println(lRangeResult4); // >>> [one, two, three]\n\n        List<String> lRangeResult5 = jedis.lrange(\"mylist\", 5, 10);\n        System.out.println(lRangeResult5); // >>> []",
      "section_id": "examples"
    },
    {
      "id": "examples-ex6",
      "language": "javascript",
      "code": "const res4 = await client.rPush('mylist', 'one');\nconsole.log(res4); // 1\n\nconst res5 = await client.rPush('mylist', 'two');\nconsole.log(res5); // 2\n\nconst res6 = await client.rPush('mylist', 'three');\nconsole.log(res6); // 3\n\nconst res7 = await client.lRange('mylist', 0, 0);\nconsole.log(res7); // [ 'one' ]\n\nconst res8 = await client.lRange('mylist', -3, 2);\nconsole.log(res8); // [ 'one', 'two', 'three' ]\n\nconst res9 = await client.lRange('mylist', -100, 100);\nconsole.log(res9); // [ 'one', 'two', 'three' ]\n\nconst res10 = await client.lRange('mylist', 5, 10);\nconsole.log(res10); // []",
      "section_id": "examples"
    },
    {
      "id": "examples-ex7",
      "language": "javascript",
      "code": "const res4 = await redis.rpush('mylist', 'one');\nconsole.log(res4); // >>> 1\n\nconst res5 = await redis.rpush('mylist', 'two');\nconsole.log(res5); // >>> 2\n\nconst res6 = await redis.rpush('mylist', 'three');\nconsole.log(res6); // >>> 3\n\nconst res7 = await redis.lrange('mylist', 0, 0);\nconsole.log(res7); // >>> ['one']\n\nconst res8 = await redis.lrange('mylist', -3, 2);\nconsole.log(res8); // >>> ['one', 'two', 'three']\n\nconst res9 = await redis.lrange('mylist', -100, 100);\nconsole.log(res9); // >>> ['one', 'two', 'three']\n\nconst res10 = await redis.lrange('mylist', 5, 10);\nconsole.log(res10); // >>> []",
      "section_id": "examples"
    },
    {
      "id": "examples-ex8",
      "language": "javascript",
      "code": "const res4 = await client.rPush('mylist', 'one');\nconsole.log(res4); // 1\n\nconst res5 = await client.rPush('mylist', 'two');\nconsole.log(res5); // 2\n\nconst res6 = await client.rPush('mylist', 'three');\nconsole.log(res6); // 3\n\nconst res7 = await client.lRange('mylist', 0, 0);\nconsole.log(res7); // [ 'one' ]\n\nconst res8 = await client.lRange('mylist', -3, 2);\nconsole.log(res8); // [ 'one', 'two', 'three' ]\n\nconst res9 = await client.lRange('mylist', -100, 100);\nconsole.log(res9); // [ 'one', 'two', 'three' ]\n\nconst res10 = await client.lRange('mylist', 5, 10);\nconsole.log(res10); // []",
      "section_id": "examples"
    },
    {
      "id": "examples-ex9",
      "language": "javascript",
      "code": "const res4 = await redis.rpush('mylist', 'one');\nconsole.log(res4); // >>> 1\n\nconst res5 = await redis.rpush('mylist', 'two');\nconsole.log(res5); // >>> 2\n\nconst res6 = await redis.rpush('mylist', 'three');\nconsole.log(res6); // >>> 3\n\nconst res7 = await redis.lrange('mylist', 0, 0);\nconsole.log(res7); // >>> ['one']\n\nconst res8 = await redis.lrange('mylist', -3, 2);\nconsole.log(res8); // >>> ['one', 'two', 'three']\n\nconst res9 = await redis.lrange('mylist', -100, 100);\nconsole.log(res9); // >>> ['one', 'two', 'three']\n\nconst res10 = await redis.lrange('mylist', 5, 10);\nconsole.log(res10); // >>> []",
      "section_id": "examples"
    },
    {
      "id": "examples-ex10",
      "language": "php",
      "code": "$res4 = $r->rpush('mylist', 'one');\n        echo $res4 . PHP_EOL;\n        // >>> 1\n\n        $res5 = $r->rpush('mylist', 'two');\n        echo $res5 . PHP_EOL;\n        // >>> 2\n\n        $res6 = $r->rpush('mylist', 'three');\n        echo $res6 . PHP_EOL;\n        // >>> 3\n\n        $res7 = $r->lrange('mylist', 0, 0);\n        echo json_encode($res7) . PHP_EOL;\n        // >>> [\"one\"]\n\n        $res8 = $r->lrange('mylist', -3, 2);\n        echo json_encode($res8) . PHP_EOL;\n        // >>> [\"one\",\"two\",\"three\"]\n\n        $res9 = $r->lrange('mylist', -100, 100);\n        echo json_encode($res9) . PHP_EOL;\n        // >>> [\"one\",\"two\",\"three\"]\n\n        $res10 = $r->lrange('mylist', 5, 10);\n        echo json_encode($res10) . PHP_EOL;\n        // >>> []",
      "section_id": "examples"
    },
    {
      "id": "examples-ex11",
      "language": "python",
      "code": "res4 = r.rpush(\"mylist\", \"one\");\nprint(res4) # >>> 1\n\nres5 = r.rpush(\"mylist\", \"two\")\nprint(res5) # >>> 2\n\nres6 = r.rpush(\"mylist\", \"three\")\nprint(res6) # >>> 3\n\nres7 = r.lrange('mylist', 0, 0)\nprint(res7) # >>> [ 'one' ]\n\nres8 = r.lrange('mylist', -3, 2)\nprint(res8) # >>> [ 'one', 'two', 'three' ]\n\nres9 = r.lrange('mylist', -100, 100)\nprint(res9) # >>> [ 'one', 'two', 'three' ]\n\nres10 = r.lrange('mylist', 5, 10)\nprint(res10) # >>> []",
      "section_id": "examples"
    },
    {
      "id": "examples-ex12",
      "language": "ruby",
      "code": "res4 = r.rpush('mylist', 'one')\nputs res4 # >>> 1\n\nres5 = r.rpush('mylist', 'two')\nputs res5 # >>> 2\n\nres6 = r.rpush('mylist', 'three')\nputs res6 # >>> 3\n\nres7 = r.lrange('mylist', 0, 0)\nputs res7.inspect # >>> [\"one\"]\n\nres8 = r.lrange('mylist', -3, 2)\nputs res8.inspect # >>> [\"one\", \"two\", \"three\"]\n\nres9 = r.lrange('mylist', -100, 100)\nputs res9.inspect # >>> [\"one\", \"two\", \"three\"]\n\nres10 = r.lrange('mylist', 5, 10)\nputs res10.inspect # >>> []",
      "section_id": "examples"
    },
    {
      "id": "examples-ex13",
      "language": "rust",
      "code": "let _: Result<i32, _> = r.rpush(\"mylist\", \"one\").await;\n        let _: Result<i32, _> = r.rpush(\"mylist\", \"two\").await;\n        let _: Result<i32, _> = r.rpush(\"mylist\", \"three\").await;\n\n        if let Ok(res7) = r.lrange(\"mylist\", 0, 0).await {\n            let res7: Vec<String> = res7;\n            println!(\"{res7:?}\"); // >>> [\"one\"]\n        }\n\n        if let Ok(res8) = r.lrange(\"mylist\", -3, 2).await {\n            let res8: Vec<String> = res8;\n            println!(\"{res8:?}\"); // >>> [\"one\", \"two\", \"three\"]\n        }\n\n        if let Ok(res9) = r.lrange(\"mylist\", -100, 100).await {\n            let res9: Vec<String> = res9;\n            println!(\"{res9:?}\"); // >>> [\"one\", \"two\", \"three\"]\n        }\n\n        if let Ok(res10) = r.lrange(\"mylist\", 5, 10).await {\n            let res10: Vec<String> = res10;\n            println!(\"{res10:?}\"); // >>> []\n        }",
      "section_id": "examples"
    },
    {
      "id": "examples-ex14",
      "language": "rust",
      "code": "let _: Result<i32, _> = r.rpush(\"mylist\", \"one\");\n        let _: Result<i32, _> = r.rpush(\"mylist\", \"two\");\n        let _: Result<i32, _> = r.rpush(\"mylist\", \"three\");\n\n        if let Ok(res7) = r.lrange(\"mylist\", 0, 0) {\n            let res7: Vec<String> = res7;\n            println!(\"{res7:?}\"); // >>> [\"one\"]\n        }\n\n        if let Ok(res8) = r.lrange(\"mylist\", -3, 2) {\n            let res8: Vec<String> = res8;\n            println!(\"{res8:?}\"); // >>> [\"one\", \"two\", \"three\"]\n        }\n\n        if let Ok(res9) = r.lrange(\"mylist\", -100, 100) {\n            let res9: Vec<String> = res9;\n            println!(\"{res9:?}\"); // >>> [\"one\", \"two\", \"three\"]\n        }\n\n        if let Ok(res10) = r.lrange(\"mylist\", 5, 10) {\n            let res10: Vec<String> = res10;\n            println!(\"{res10:?}\"); // >>> []\n        }",
      "section_id": "examples"
    }
  ]
}
