{
  "schema_version": 2,
  "id": "commands/lrem",
  "title": "LREM",
  "url": "https://redis.io/docs/latest/commands/lrem/",
  "summary": "Removes elements from a list. Deletes the list if the last element was removed.",
  "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": "9082070e1c527a3599810d008d2bf861c7a665644a1ca5b45c8b10ee25e908eb",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "Removes the first `count` occurrences of elements equal to `element` from the list\nstored at `key`.\nThe `count` argument influences the operation in the following ways:\n\n* `count > 0`: Remove elements equal to `element` moving from head to tail.\n* `count < 0`: Remove elements equal to `element` moving from tail to head.\n* `count = 0`: Remove all elements equal to `element`.\n\nFor example, `LREM list -2 \"hello\"` will remove the last two occurrences of\n`\"hello\"` in the list stored at `key`.\n\nNote that non-existing keys are treated like empty lists, so when `key` does not\nexist, the command will always return `0`."
    },
    {
      "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>count</code></summary>\n\nThe number of matching elements to remove and the direction: a positive value removes from the head, a negative value from the tail, and `0` removes all matches.\n\n</details>\n\n<details open><summary><code>element</code></summary>\n\nThe value to remove.\n\n</details>"
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "redis> RPUSH mylist \"hello\"\n(integer) 1\nredis> RPUSH mylist \"hello\"\n(integer) 2\nredis> RPUSH mylist \"foo\"\n(integer) 3\nredis> RPUSH mylist \"hello\"\n(integer) 4\nredis> LREM mylist -2 \"hello\"\n(integer) 2\nredis> LRANGE mylist 0 -1\n1) \"hello\"\n2) \"foo\""
    },
    {
      "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[Integer reply](../../develop/reference/protocol-spec#integers): the number of removed elements.\n\n**RESP3:**\n\n[Integer reply](../../develop/reference/protocol-spec#integers): the number of removed elements."
    }
  ],
  "examples": []
}
