iLoveConverter
Categories 11 categories
Data MessagePack

MessagePack, Explained

iLoveConverter Team 2 min read

On this page

MessagePack is a compact binary serialization format — designed by Sadayuki Furuhashi in 2008 as a faster, smaller alternative to JSON. Like CBOR, it represents the same data structures (maps, arrays, strings, integers, floats, booleans, null, binary, timestamps) as JSON but encodes them as typed binary bytes instead of text. For modern APIs and data pipelines, MessagePack is often the right choice when you want JSON’s flexibility without JSON’s verbosity.

Technical details

MessagePack uses type prefix bytes to identify each value: positive fixint (0x00–0x7f), negative fixint (0xe0–0xff), fixstr, fixarray, fixmap — values up to 127 integers, 31-character strings, 15-item arrays, and 15-key maps all encode in a single byte prefix + payload. Binary data has a dedicated type (no base64 needed). Timestamps are a MessagePack extension type (type code 0xd4–0xd6 for various widths). No delimiters, no whitespace, no escaping.

FeatureMessagePackJSONCBORProtocol Buffers
FormatBinaryTextBinaryBinary
Size vs JSON50–80%100%40–70%20–40%
Schema requiredNoNoNoYes
Human-readableNoYesNoNo
Timestamp supportExtension typeNone (ISO string)Built-in tagYes (int64)
Language supportExcellentUniversalGoodVery good

Conversion

MessagePack ↔ JSON conversion is nearly 1:1 — every MessagePack value maps cleanly to JSON (timestamps become ISO strings, binary becomes base64). Use msgpack2json CLI or any language’s MessagePack library. MessagePack ↔ CBOR also converts cleanly; the main difference is CBOR has richer tag support for semantic types.

Common problems

  • No self-description. Binary format with no schema — impossible to inspect without a decoder.
  • Extension type ambiguity. Timestamps use extension type 0xff; other extension types vary by implementation.
  • Big-endian integers. All integers in MessagePack are big-endian, which is efficient on most CPUs but requires swapping on little-endian systems (MessagePack libraries handle this automatically).

FAQ

Is MessagePack faster than JSON?

Yes — significantly. Encoding is 3–5x faster, decoding 2–4x faster, and payloads are typically 20–50% smaller. The only reason JSON dominates is human readability and ubiquity.

What’s the difference between MessagePack and CBOR?

MessagePack is simpler and slightly more compact for integers. CBOR has semantic tags (for timestamps, URIs, dates), indefinite-length streaming, and a deterministic encoding spec. Choose MessagePack when you want speed and simplicity; CBOR when you need tags or determinism.

Does MessagePack support Unicode?

Yes — fixstr stores valid UTF-8 strings natively, and binary data has a separate type. No base64 needed for binary data, unlike JSON.

Is MessagePack used in production?

Extensively — Fluentd, Graylog, Apache Arrow (via MessagePack IPC), and many NoSQL databases use it as an internal serialization format. Discord uses it for some API payloads.

Can I use MessagePack in the browser?

Yes — msgpack-lite and @msgpack/msgpack are popular npm packages that work in Node.js and browser environments. Modern implementations are fast enough for real-time data pipelines.

Try it yourself — free, right in your browser

Everything mentioned in this guide runs locally on this site: no upload, no watermark, no sign-up.

Format deep-dives: MSGPACK (.msgpack) , JSON (.json)