# COMMAND GETKEYS

```json metadata
{
  "title": "COMMAND GETKEYS",
  "description": "Extracts the key names from an arbitrary command.",
  "categories": ["docs","develop","stack","oss","rs","rc","oss","kubernetes","clients"],
  "arguments": [{"display_text":"command","name":"command","type":"string"},{"display_text":"arg","multiple":true,"name":"arg","optional":true,"type":"string"}],
  "syntax_fmt": "COMMAND GETKEYS command [arg [arg ...]]",
  "complexity": "O(N) where N is the number of arguments to the command",
  "group": "server",
  "command_flags": ["loading","stale"],
  "acl_categories": ["@slow","@connection"],
  "since": "2.8.13",
  "arity": -3,
  "tableOfContents": {"sections":[{"id":"examples","title":"Examples"},{"id":"redis-enterprise-and-redis-cloud-compatibility","title":"Redis Enterprise and Redis Cloud compatibility"},{"id":"return-information","title":"Return information"}]}
}
```













Returns [Array reply](https://redis.io/docs/latest/develop/reference/protocol-spec#arrays) of keys from a full Redis command.

`COMMAND GETKEYS` is a helper command to let you find the keys
from a full Redis command.

[`COMMAND`](https://redis.io/docs/latest/commands/command) provides information on how to find the key names of each command (see `firstkey`, [key specifications](https://redis.io/docs/latestdevelop/reference/key-specs#logical-operation-flags), and `movablekeys`),
but in some cases it's not possible to find keys of certain commands and then the entire command must be parsed to discover some / all key names.
You can use `COMMAND GETKEYS` or [`COMMAND GETKEYSANDFLAGS`](https://redis.io/docs/latest/commands/command-getkeysandflags) to discover key names directly from how Redis parses the commands.

## Examples


COMMAND GETKEYS MSET a b c d e f
COMMAND GETKEYS EVAL "not consulted" 3 key1 key2 key3 arg1 arg2 arg3 argN
COMMAND GETKEYS SORT mylist ALPHA STORE outlist


## Redis Enterprise and Redis Cloud compatibility

| Redis<br />Enterprise | Redis<br />Cloud | <span style="min-width: 9em; display: table-cell">Notes</span> |
|:----------------------|:-----------------|:------|
| <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> |  |

## Return information

{{< multitabs id="command-getkeys-return-info" 
    tab1="RESP2" 
    tab2="RESP3" >}}

[Array reply](../../develop/reference/protocol-spec#arrays): list of keys from the given command.

-tab-sep-

[Array reply](../../develop/reference/protocol-spec#arrays): a list of keys from the given command.


