# HGETALL

> Get all fields and values of a hash.

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

```
HGETALL key
```

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

`HGETALL` returns every field of the hash stored at `key` together with its
value. The order is not defined. For large hashes, prefer
[HSCAN](https://docs.hotkv.com/commands/hscan/index.md).

## Return value

| Case | RESP2 | RESP3 |
| --- | --- | --- |
| Hash exists | Flat array: field, value, field, value, ... | Map of field to value |
| Key does not exist | Empty array | Empty map |

`HGETALL` 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> HGETALL user:1
1) "name"
2) "Ada"
3) "lang"
4) "en"
```

With RESP3 (`redis-cli -3`):

```
127.0.0.1:6379> HGETALL user:1
1# "name" => "Ada"
2# "lang" => "en"
```

## Compatibility

Same as Redis 7.4 and Valkey 8.

## See also

[HKEYS](https://docs.hotkv.com/commands/hkeys/index.md), [HVALS](https://docs.hotkv.com/commands/hvals/index.md), [HMGET](https://docs.hotkv.com/commands/hmget/index.md),
[HSCAN](https://docs.hotkv.com/commands/hscan/index.md), [HRANDFIELD](https://docs.hotkv.com/commands/hrandfield/index.md)