# HKEYS

> Get all field names of a hash.

URL: https://docs.hotkv.com/commands/hkeys/

```
HKEYS key
```

- Group: Hash
- Complexity: O(N) where N is the size of the hash
- HotKV Cloud: all plans
- On-Premise: no license needed

`HKEYS` returns every field name in the hash stored at `key`. The order is not
defined. For large hashes, prefer [HSCAN](https://docs.hotkv.com/commands/hscan/index.md) so a single reply
does not carry the whole hash.

## Return value

| Case | RESP2 | RESP3 |
| --- | --- | --- |
| Hash exists | Array of bulk strings: the field names | Same |
| Key does not exist | Empty array | Same |

`HKEYS` replies with a `WRONGTYPE` error if `key` holds a value that is not a
hash.

## Examples

```
127.0.0.1:6379> HSET user:1 name "Ada" lang "en"
(integer) 2
127.0.0.1:6379> HKEYS user:1
1) "name"
2) "lang"
127.0.0.1:6379> HKEYS nosuchkey
(empty array)
```

## Compatibility

Same as Redis 7.4 and Valkey 8.

## See also

[HVALS](https://docs.hotkv.com/commands/hvals/index.md), [HGETALL](https://docs.hotkv.com/commands/hgetall/index.md), [HSCAN](https://docs.hotkv.com/commands/hscan/index.md),
[HLEN](https://docs.hotkv.com/commands/hlen/index.md)