{
  "schema_version": 2,
  "id": "commands/lpop",
  "title": "LPOP",
  "url": "https://redis.io/docs/latest/commands/lpop/",
  "summary": "Returns the first elements in a list after removing it. Deletes the list if the last element was popped.",
  "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": "1e5a2a4f9cfe539907ef9a98a33948e59d96bd9d6a68e2d054b4f4b9742d1fed",
  "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>"
    },
    {
      "id": "optional-arguments",
      "title": "Optional arguments",
      "role": "parameters",
      "text": "<details open><summary><code>count</code></summary>\n\nThe number of elements to pop. Without it, a single element is popped.\n\n</details>"
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "Foundational: Remove and return the first element(s) from a list using LPOP (supports optional count parameter to pop multiple elements)\n\n**Difficulty:** Beginner\n\n**Commands:** RPUSH, LPOP, LRANGE\n\n**Complexity:**\n- RPUSH: O(1)\n- LPOP: O(N)\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": "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.\n* [Bulk string reply](../../develop/reference/protocol-spec#bulk-strings): when called without the _count_ argument, the value of the first element.\n* [Array reply](../../develop/reference/protocol-spec#arrays): when called with the _count_ argument, a list of popped elements.\n\n**RESP3:**\n\nOne of the following:\n* [Null reply](../../develop/reference/protocol-spec#nulls): if the key does not exist.\n* [Bulk string reply](../../develop/reference/protocol-spec#bulk-strings): when called without the _count_ argument, the value of the first element.\n* [Array reply](../../develop/reference/protocol-spec#arrays): when called with the _count_ argument, a list of popped elements."
    }
  ],
  "examples": [
    {
      "id": "examples-ex0",
      "language": "plaintext",
      "code": "redis> RPUSH mylist \"one\" \"two\" \"three\" \"four\" \"five\"\n(integer) 5\nredis> LPOP mylist\n\"one\"\nredis> LPOP mylist 2\n1) \"two\"\n2) \"three\"\nredis> LRANGE mylist 0 -1\n1) \"four\"\n2) \"five\"",
      "section_id": "examples"
    },
    {
      "id": "examples-ex1",
      "language": "csharp",
      "code": "long lPopResult1 = db.ListRightPush(\"mylist\", [\"one\", \"two\", \"three\", \"four\", \"five\"]);\n        Console.WriteLine(lPopResult1); // >>> 5\n\n        RedisValue lPopResult2 = db.ListLeftPop(\"mylist\");\n        Console.WriteLine(lPopResult2); // >>> one\n\n        RedisValue[] lPopResult3 = db.ListLeftPop(\"mylist\", 2);\n        Console.WriteLine($\"[{string.Join(\", \", lPopResult3)}]\");\n        // >>> [two, three]\n\n        RedisValue[] lPopResult4 = db.ListRange(\"mylist\", 0, -1);\n        Console.WriteLine($\"[{string.Join(\", \", lPopResult4)}]\");\n        // >>> [four, five]",
      "section_id": "examples"
    },
    {
      "id": "examples-ex2",
      "language": "go",
      "code": "RPushResult, err := rdb.RPush(ctx,\n\t\t\"mylist\", \"one\", \"two\", \"three\", \"four\", \"five\",\n\t).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(RPushResult) // >>> 5\n\n\tlPopResult, err := rdb.LPop(ctx, \"mylist\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(lPopResult) // >>> one\n\n\tlPopCountResult, err := rdb.LPopCount(ctx, \"mylist\", 2).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(lPopCountResult) // >>> [two three]\n\n\tlRangeResult, err := rdb.LRange(ctx, \"mylist\", 0, -1).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(lRangeResult) // >>> [four five]",
      "section_id": "examples"
    },
    {
      "id": "examples-ex3",
      "language": "java",
      "code": "CompletableFuture<Void> lpop = asyncCommands.rpush(\"mylist\", \"one\", \"two\", \"three\", \"four\", \"five\")\n                    .thenCompose(res17 -> {\n                        System.out.println(res17); // >>> 5\n\n                        return asyncCommands.lpop(\"mylist\");\n                    }).thenCompose(res18 -> {\n                        System.out.println(res18); // >>> one\n\n                        return asyncCommands.lpop(\"mylist\", 2);\n                    }).thenCompose(res19 -> {\n                        System.out.println(res19); // >>> [two, three]\n\n                        return asyncCommands.lrange(\"mylist\", 0, -1);\n                    })\n                    .thenAccept(res17_final -> System.out.println(res17_final)) // >>> [four, five]\n                    .toCompletableFuture();",
      "section_id": "examples"
    },
    {
      "id": "examples-ex4",
      "language": "java",
      "code": "Mono<Void> lpop = reactiveCommands.rpush(\"mylist\", \"one\", \"two\", \"three\", \"four\", \"five\").doOnNext(res17 -> {\n                System.out.println(res17); // >>> 5\n            }).flatMap(res17 -> reactiveCommands.lpop(\"mylist\")).doOnNext(res18 -> {\n                System.out.println(res18); // >>> one\n            }).flatMap(res18 -> reactiveCommands.lpop(\"mylist\", 2).collectList()).doOnNext(res19 -> {\n                System.out.println(res19); // >>> [two, three]\n            }).flatMap(res19 -> reactiveCommands.lrange(\"mylist\", 0, -1).collectList()).doOnNext(res17_final -> {\n                System.out.println(res17_final); // >>> [four, five]\n            }).then();",
      "section_id": "examples"
    },
    {
      "id": "examples-ex5",
      "language": "java",
      "code": "long lPopResult1 = jedis.rpush(\n            \"mylist\", \"one\", \"two\", \"three\", \"four\", \"five\"\n        );\n        System.out.println(lPopResult1); // >>> 5\n\n        String lPopResult2 = jedis.lpop(\"mylist\");\n        System.out.println(lPopResult2); // >>> one\n\n        List<String> lPopResult3 = jedis.lpop(\"mylist\", 2);\n        System.out.println(lPopResult3); // >>> [two, three]\n\n        List<String> lPopResult4 = jedis.lrange(\"mylist\", 0, -1);\n        System.out.println(lPopResult4); // >>> [four, five]",
      "section_id": "examples"
    },
    {
      "id": "examples-ex6",
      "language": "javascript",
      "code": "const res17 = await client.rPush('mylist', [\"one\", \"two\", \"three\", \"four\", \"five\"]);\nconsole.log(res17); // 5\n\nconst res18 = await client.lPop('mylist');\nconsole.log(res18); // 'one'\n\nconst res19 = await client.lPopCount('mylist', 2);\nconsole.log(res19); // [ 'two', 'three' ]\n\nconst res20 = await client.lRange('mylist', 0, -1);\nconsole.log(res20); // [ 'four', 'five' ]",
      "section_id": "examples"
    },
    {
      "id": "examples-ex7",
      "language": "javascript",
      "code": "const res17 = await redis.rpush('mylist', 'one', 'two', 'three', 'four', 'five');\nconsole.log(res17); // >>> 5\n\nconst res18 = await redis.lpop('mylist');\nconsole.log(res18); // >>> one\n\nconst res19 = await redis.lpop('mylist', 2);\nconsole.log(res19); // >>> ['two', 'three']\n\nconst res20 = await redis.lrange('mylist', 0, -1);\nconsole.log(res20); // >>> ['four', 'five']",
      "section_id": "examples"
    },
    {
      "id": "examples-ex8",
      "language": "javascript",
      "code": "const res17 = await client.rPush('mylist', [\"one\", \"two\", \"three\", \"four\", \"five\"]);\nconsole.log(res17); // 5\n\nconst res18 = await client.lPop('mylist');\nconsole.log(res18); // 'one'\n\nconst res19 = await client.lPopCount('mylist', 2);\nconsole.log(res19); // [ 'two', 'three' ]\n\nconst res20 = await client.lRange('mylist', 0, -1);\nconsole.log(res20); // [ 'four', 'five' ]",
      "section_id": "examples"
    },
    {
      "id": "examples-ex9",
      "language": "javascript",
      "code": "const res17 = await redis.rpush('mylist', 'one', 'two', 'three', 'four', 'five');\nconsole.log(res17); // >>> 5\n\nconst res18 = await redis.lpop('mylist');\nconsole.log(res18); // >>> one\n\nconst res19 = await redis.lpop('mylist', 2);\nconsole.log(res19); // >>> ['two', 'three']\n\nconst res20 = await redis.lrange('mylist', 0, -1);\nconsole.log(res20); // >>> ['four', 'five']",
      "section_id": "examples"
    },
    {
      "id": "examples-ex10",
      "language": "php",
      "code": "$res17 = $r->rpush('mylist', 'one', 'two', 'three', 'four', 'five');\n        echo $res17 . PHP_EOL;\n        // >>> 5\n\n        $res18 = $r->lpop('mylist');\n        echo $res18 . PHP_EOL;\n        // >>> one\n\n        $res19 = $r->lpop('mylist', 2);\n        echo json_encode($res19) . PHP_EOL;\n        // >>> [\"two\",\"three\"]\n\n        $res20 = $r->lrange('mylist', 0, -1);\n        echo json_encode($res20) . PHP_EOL;\n        // >>> [\"four\",\"five\"]",
      "section_id": "examples"
    },
    {
      "id": "examples-ex11",
      "language": "python",
      "code": "res17 = r.rpush(\"mylist\", *[\"one\", \"two\", \"three\", \"four\", \"five\"])\nprint(res17) # >>> 5\n\nres18 = r.lpop(\"mylist\")\nprint(res18) # >>> \"one\"\n\nres19 = r.lpop(\"mylist\", 2)\nprint(res19) # >>> ['two', 'three']\n\nres17 = r.lrange(\"mylist\", 0, -1)\nprint(res17)  # >>> [ \"four\", \"five\" ]",
      "section_id": "examples"
    },
    {
      "id": "examples-ex12",
      "language": "ruby",
      "code": "res17 = r.rpush('mylist', ['one', 'two', 'three', 'four', 'five'])\nputs res17 # >>> 5\n\nres18 = r.lpop('mylist')\nputs res18 # >>> one\n\nres19 = r.lpop('mylist', 2)\nputs res19.inspect # >>> [\"two\", \"three\"]\n\nres20 = r.lrange('mylist', 0, -1)\nputs res20.inspect # >>> [\"four\", \"five\"]",
      "section_id": "examples"
    },
    {
      "id": "examples-ex13",
      "language": "rust",
      "code": "if let Ok(res17) = r.rpush(\"mylist\", &[\"one\", \"two\", \"three\", \"four\", \"five\"]).await {\n            let res17: i32 = res17;\n            println!(\"{res17}\"); // >>> 5\n        }\n\n        if let Ok(res18) = r.lpop(\"mylist\", None).await {\n            let res18: String = res18;\n            println!(\"{res18}\"); // >>> one\n        }\n\n        if let Ok(res19) = r.lpop(\"mylist\", NonZeroUsize::new(2)).await {\n            let res19: Vec<String> = res19;\n            println!(\"{res19:?}\"); // >>> [\"two\", \"three\"]\n        }\n\n        if let Ok(res20) = r.lrange(\"mylist\", 0, -1).await {\n            let res20: Vec<String> = res20;\n            println!(\"{res20:?}\"); // >>> [\"four\", \"five\"]\n        }",
      "section_id": "examples"
    },
    {
      "id": "examples-ex14",
      "language": "rust",
      "code": "if let Ok(res17) = r.rpush(\"mylist\", &[\"one\", \"two\", \"three\", \"four\", \"five\"]) {\n            let res17: i32 = res17;\n            println!(\"{res17}\"); // >>> 5\n        }\n\n        if let Ok(res18) = r.lpop(\"mylist\", None) {\n            let res18: String = res18;\n            println!(\"{res18}\"); // >>> one\n        }\n\n        if let Ok(res19) = r.lpop(\"mylist\", NonZeroUsize::new(2)) {\n            let res19: Vec<String> = res19;\n            println!(\"{res19:?}\"); // >>> [\"two\", \"three\"]\n        }\n\n        if let Ok(res20) = r.lrange(\"mylist\", 0, -1) {\n            let res20: Vec<String> = res20;\n            println!(\"{res20:?}\"); // >>> [\"four\", \"five\"]\n        }",
      "section_id": "examples"
    }
  ]
}
