{
  "schema_version": 2,
  "id": "commands/sunion",
  "title": "SUNION",
  "url": "https://redis.io/docs/latest/commands/sunion/",
  "summary": "Returns the union of multiple sets.",
  "since": "1.0.0",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-09-18T09:47:41+01:00",
  "page_type": "content",
  "content_hash": "ea7c63510edbffdc38b22adc2964497bcf3ee8d1b132032ad51eea275433ba0c",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "> [!NOTE]\n> This command's behavior varies in clustered Redis environments. See the [multi-key operations](https://redis.io/docs/latest/develop/using-commands/multi-key-operations) page for more information.\n\n\nReturns the members of the set resulting from the union of all the given sets.\n\nFor example:\n\n[code example]\n\nKeys that do not exist are considered to be empty sets."
    },
    {
      "id": "required-arguments",
      "title": "Required arguments",
      "role": "content",
      "text": "<details open><summary><code>key [key ...]</code></summary>\n\nOne or more set keys to union.\n\n</details>"
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "redis> SADD key1 \"a\"\n(integer) 1\nredis> SADD key1 \"b\"\n(integer) 1\nredis> SADD key1 \"c\"\n(integer) 1\nredis> SADD key2 \"c\"\n(integer) 1\nredis> SADD key2 \"d\"\n(integer) 1\nredis> SADD key2 \"e\"\n(integer) 1\nredis> SUNION key1 key2\n1) \"a\"\n2) \"c\"\n3) \"d\"\n4) \"e\"\n5) \"b\""
    },
    {
      "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 with members of the resulting set.\n\n**RESP3:**\n\n[Set reply](../../develop/reference/protocol-spec#sets): a set with the members of the resulting set."
    },
    {
      "id": "see-also",
      "title": "See also",
      "role": "related",
      "text": "[`SUNIONCARD`](https://redis.io/docs/latest/commands/sunioncard) | [`SUNIONSTORE`](https://redis.io/docs/latest/commands/sunionstore)"
    }
  ],
  "examples": [
    {
      "id": "overview-ex0",
      "language": "plaintext",
      "code": "key1 = {a,b,c,d}\nkey2 = {c}\nkey3 = {a,c,e}\nSUNION key1 key2 key3 = {a,b,c,d,e}",
      "section_id": "overview"
    }
  ]
}
