# OBJECT ENCODING

> Return the encoding name of the value stored at a key.

URL: https://docs.hotkv.com/commands/object-encoding/

```
OBJECT ENCODING key
```

- Group: Keys
- Complexity: O(1)
- HotKV Cloud: all plans
- On-Premise: no license needed

`OBJECT ENCODING` returns the name of the encoding used for the value at
`key`. Small collections use a compact encoding and switch to a general one
once they grow past the configured size limits; tools written for Redis that
check these names keep working.

| Type | Possible encodings |
| --- | --- |
| String | `int` (a 64-bit integer), `embstr`, `raw` |
| List | `listpack`, `quicklist` |
| Set | `intset`, `listpack`, `hashtable` |
| Hash | `listpack`, `listpackex` (compact, with field expiry), `hashtable` |
| Sorted set | `listpack`, `skiplist` |
| Stream | `stream` |
| Bloom filter, count-min sketch, Top-K | `raw` |

Looking at a key with `OBJECT` is not an access to it.

## Return value

| Case | RESP2 | RESP3 |
| --- | --- | --- |
| The key exists | Bulk string: the encoding name | Bulk string |
| The key does not exist | Nil bulk string | Null |

## Examples

```
127.0.0.1:6379> SET counter 12345
OK
127.0.0.1:6379> OBJECT ENCODING counter
"int"
127.0.0.1:6379> SET name "ada"
OK
127.0.0.1:6379> OBJECT ENCODING name
"embstr"
127.0.0.1:6379> SADD ids 1 2 3
(integer) 3
127.0.0.1:6379> OBJECT ENCODING ids
"intset"
127.0.0.1:6379> OBJECT ENCODING missing
(nil)
```

## Compatibility

Same encoding names as Redis 7.4. The probabilistic types report `raw`.

## See also

[OBJECT](https://docs.hotkv.com/commands/object/index.md), [TYPE](https://docs.hotkv.com/commands/type/index.md),
[OBJECT FREQ](https://docs.hotkv.com/commands/object-freq/index.md)