RESP Type Reference
RESP (Redis Serialization Protocol) uses single-byte prefixes to identify data types. RESP2 has 5 types. RESP3 (Redis 6.0+, opt-in via HELLO 3) adds 9 new types including map, set, double, boolean, and push for server-initiated out-of-band data.
5
RESP2 types
6
RESP3 new types
| Prefix | Type name | Version | |
|---|---|---|---|
| + | Simple String | RESP2 | |
| - | Simple Error | RESP2 | |
| : | Integer | RESP2 | |
| $ | Bulk String | RESP2 | |
| * | Array | RESP2 | |
| _ | Null | RESP3 | |
| , | Double | RESP3 | |
| # | Boolean | RESP3 | |
| % | Map | RESP3 | |
| ~ | Set | RESP3 | |
| > | Push | RESP3 |
RESP2 types
Available since Redis 2.0 (2010). Default for all clients that do not send HELLO 3.
String / str in most languages
Simple strings are non-binary-safe strings terminated by CRLF. The + prefix signals a single-line string that cannot contain \r or \n characters. Used for short server replies like +OK, +PONG, and +QUEUED. For binary-safe string data, use bulk strings ($).
Exception / Error / exception class
Simple errors use the - prefix to signal command failures. The first word in upper case is the error code; the remainder is the human-readable message. Common codes: ERR (generic), WRONGTYPE (type mismatch), NOAUTH (authentication required), NOPERM (ACL permission denied).
Integer / int / Long
Integers use the : prefix and represent a signed 64-bit integer value. Used for command results that are naturally numeric: INCR/DECR return values, LLEN/SCARD counts, EXPIRE success/failure (1/0), PUBLISH subscriber count. The special values 0 and 1 are also used as boolean equivalents for commands that return success/failure.
String / bytes / Optional[str]
Bulk strings are binary-safe strings with an explicit length prefix. Format: $<length>\r\n<bytes>\r\n. The length prefix allows the string to contain any bytes including \r and \n. $-1\r\n represents a null bulk string. Used for most string data returned by Redis: GET values, HGET field values, LRANGE elements.
List / Array / []
Arrays contain an ordered sequence of other RESP types. Format: *<count>\r\n followed by count elements. Arrays can be nested. *-1\r\n is a null array. Used for multi-value replies: LRANGE list elements, KEYS, HMGET values. In RESP3, SMEMBERS returns a ~ set and HGETALL returns a % map instead of flat arrays.
RESP3 types
New in Redis 6.0 (2020). Opt-in via HELLO 3. RESP3 is a superset of RESP2 – all RESP2 types remain valid.
nil / None / null / nullptr
RESP3 introduces a unified null type: _\r\n. This replaces RESP2's two null representations ($-1\r\n null bulk string and *-1\r\n null array), which were semantically identical but required clients to track which null form applied to which command.
float / double / Float64
RESP3 doubles carry IEEE 754 floating-point values natively. Format: ,<number>\r\n. Supports ,inf\r\n and ,-inf\r\n for infinity. Previously, Redis returned floats as bulk strings (e.g., ZSCORE returned '$4\r\n1.25\r\n'), requiring clients to parse the string. RESP3 doubles let clients receive native float/double values directly.
bool / Boolean / true/false
RESP3 booleans encode true and false explicitly: #t\r\n and #f\r\n. In RESP2, boolean-semantic commands returned integers (1=true, 0=false). RESP3 booleans let clients receive proper boolean types for commands like SISMEMBER, HEXISTS, and EXPIRE without knowing the command's boolean-integer convention.
dict / HashMap / Map<K,V> / object
RESP3 maps encode key-value dictionaries natively. Format: %<count>\r\n followed by count×2 elements (alternating keys and values). HGETALL, CONFIG GET, and XAUTOCLAIM now return maps instead of flat alternating arrays. Clients can return native dict/HashMap/object without knowing the command name.
set / Set / HashSet / frozenset
RESP3 sets encode unordered collections with test-for-existence semantics. Format: ~<count>\r\n followed by count elements. SMEMBERS, SUNION, SDIFF, and SINTER now return sets instead of arrays in RESP3. Clients return native set types (Python set, Ruby Set, Java HashSet) without needing to know the command name.
callback / event / async handler
Push data is the most architecturally significant RESP3 addition. A > frame is sent by the server at any time, interleaved with regular replies, without being a response to a command. The first element identifies the push type (pubsub, monitor, keyspace, etc.). Clients invoke registered callbacks. RESP3 push allows pub/sub subscriptions on the same connection used for regular commands.
Upgrade to RESP3: Send HELLO 3 at connection startup. The server replies with a map of server info (server, version, proto, id, mode, role, modules). After HELLO 3, HGETALL returns a map (%), SMEMBERS returns a set (~), and SISMEMBER returns a boolean (#). Clients can downgrade with HELLO 2.