MessagePack Codec
Encode and decode MessagePack binary serialization format
Paste MessagePack data from API responses, log files, or network captures
Click to Insert Example Data
Decoded Result
Enter MessagePack data and click Decode to see results
Byte Viewer
Enter valid JSON data to encode as MessagePack
Container Length Encoding
- Compact: Uses minimum bytes (fixarray/fixmap when ≤15 items)
- Explicit 16-bit: Always uses 2-byte length (array16/map16 format)
- Explicit 32-bit: Always uses 4-byte length (array32/map32 format)
Click to Insert JSON Example
Encoded Result
Enter JSON data and click Encode to generate MessagePack
Byte Viewer
Encoding Statistics
MessagePack Data Types Reference
| Type Name | Format Byte Range | Description |
|---|---|---|
| Positive FixInt | 0x00-0x7F | Integers from 0 to 127 (single byte) |
| Negative FixInt | 0xE0-0xFF | Integers from -32 to -1 (single byte) |
| FixMap | 0x80-0x8F | Maps with 0-15 key-value pairs |
| FixArray | 0x90-0x9F | Arrays with 0-15 elements |
| FixStr | 0xA0-0xBF | Strings with 0-31 bytes length |
| Nil | 0xC0 | Represents null/nil value |
| Boolean | 0xC2-0xC3 | True (0xc3) or False (0xc2) |
| Binary | 0xC4-0xC6 | Raw binary data (bin8/bin16/bin32) |
| Extension | 0xC7-0xC9, 0xD4-0xD8 | Application-specific types with type code |
| Float | 0xCA-0xCB | 32-bit or 64-bit floating point numbers |
| Unsigned Integer | 0xCC-0xCF | 8/16/32/64-bit unsigned integers |
| Signed Integer | 0xD0-0xD3 | 8/16/32/64-bit signed integers |
| String | 0xD9-0xDB | UTF-8 strings (str8/str16/str32) |
| Array | 0xDC-0xDD | Arrays with 16-bit or 32-bit length |
| Map | 0xDE-0xDF | Maps with 16-bit or 32-bit length |
MessagePack Protocol Documentation
What is MessagePack
MessagePack is a binary serialization format designed for efficient data exchange. Created by Sadayuki Furuhashi in 2008, it packs JSON-like data structures into a compact binary representation that's typically 50% smaller than JSON while being faster to parse. The format is widely adopted in Redis, Fluentd, and numerous real-time communication systems where performance matters.
Binary Encoding Structure
MessagePack uses a type-length-value encoding scheme. The first byte (format byte) determines the data type and may contain the value itself for small integers and short strings. Larger values use additional bytes for length and payload. This design allows MessagePack to encode small values extremely efficiently while still supporting large data structures.
| Format Byte | Meaning |
|---|---|
| 0x00-0x7F | Positive fixint (0-127, value in byte) |
| 0x80-0x8F | Fixmap (0-15 pairs, count in lower 4 bits) |
| 0x90-0x9F | Fixarray (0-15 elements, count in lower 4 bits) |
| 0xA0-0xBF | Fixstr (0-31 bytes, length in lower 5 bits) |
| 0xC0-0xDF | Nil, boolean, bin, ext, float, int types |
| 0xE0-0xFF | Negative fixint (-32 to -1) |
MessagePack vs JSON Comparison
Both formats represent the same data model but optimize for different scenarios. MessagePack prioritizes compact size and parsing speed, making it ideal for high-throughput systems. JSON prioritizes human readability and universal compatibility across all platforms.
- 30-50% smaller than JSON
- Native binary data support
- Faster serialization and parsing
- Type-safe with distinct integer types
- Human readable and editable
- Universal browser and language support
- Easier debugging and logging
Common Applications
- Redis data serialization and caching
- Real-time communication protocols (gaming, chat)
- Fluentd log aggregation and forwarding
- RPC frameworks (MessagePack-RPC)
- Mobile and embedded applications with bandwidth constraints
Extension Types
MessagePack supports application-defined extension types. Each extension has a type code (integer from -128 to 127) and binary payload. Common standard extensions include timestamp (type -1), which stores seconds and nanoseconds for precise time representation.
| Type Code | Common Usage |
|---|---|
| -1 | Timestamp (official) |
| 0-127 | Application-defined types |
Related Tools
CBOR Codec
Encode and decode CBOR binary format with JSON conversion, hex viewer, and semantic tag support for IoT development
JSON Formatter
Format and validate JSON data for improved readability and debugging
Base64 Encoder/Decoder
Quickly encode and decode Base64 strings, supporting both text and file conversion
Protocol Buffers Tool
Online Protocol Buffers encoder/decoder. Parse .proto schemas, encode JSON to binary, or decode binary to JSON