What MessagePack is
MessagePack is a binary serialization format that encodes the same data model as JSON — objects, arrays, strings, numbers, booleans, null — but in a binary representation roughly 30-50% smaller and significantly faster to parse. Designed by Sadayuki Furuhashi in 2008, it has implementations in 50+ languages and is the wire format behind Treasure Data's pipeline and Fluentd, and the serialization format Redis ships for Lua scripting via the cmsgpack module.
MessagePack is a drop-in replacement for JSON when you control both ends of the wire. The data model is identical, so any program that round-trips JSON can round-trip MessagePack without code changes apart from the encoder/decoder swap.
Wire comparison
The same payload in both formats:
// JSON — 38 bytes
{"id":1,"name":"Ada","active":true}
// MessagePack — 22 bytes (hex)
83 a2 69 64 01 a4 6e 61 6d 65 a3 41 64 61 a6 61 63 74 69 76 65 c3
// Breakdown:
83 // map with 3 entries
a2 69 64 // "id" (2-byte string)
01 // integer 1
a4 6e 61 6d 65 // "name" (4-byte string)
a3 41 64 61 // "Ada" (3-byte string)
a6 61 63 74 69 76 65 // "active" (6-byte string)
c3 // trueTwo things to notice. First, MessagePack omits the JSON punctuation entirely — no quotes, no commas, no colons. Second, numbers and booleans are packed into single bytes for small values. Type information is in the high bits of each token.
Size savings depend on the payload shape. Object-heavy data (many keys, short values) saves the most because the punctuation is most of the JSON. Number-heavy data saves less because both formats need similar byte counts for arbitrary precision.
Speed in real numbers
On a modern CPU, parsing typical API payloads:
- V8
JSON.parse— ~250 MB/s msgpackr(npm) — ~700 MB/s, about 2.8× faster- simd-json — ~1.5 GB/s, fastest but only for JSON
Encoding speed is similar — MessagePack encodes faster than JSON because it skips the UTF-8 string escape pass. The byte count savings give it a further advantage at the network layer: less bytes to transfer means less time waiting for the socket.
The numbers above are for an in-process benchmark. End-to-end (including HTTP, gzip, application logic) the speedup is usually 1.2-1.5× rather than 2.8× because parsing is rarely the bottleneck. Profile before assuming the swap will help.
When to switch from JSON
Three patterns where MessagePack is clearly worth it:
High-throughput internal RPC. Service-to-service calls in your own infrastructure, especially when you measure latency in milliseconds. The smaller payload reduces socket round-trip count and the faster parse reduces CPU contention.
Persisted blobs read repeatedly. Cached objects in Redis or memcached, session payloads in cookies (where the size limit is tight), serialized values in object storage. Every read avoids the JSON parse overhead.
Streaming pipelines. Kafka topics, log streams, sensor telemetry. The throughput multiplies — a 30% size saving across a petabyte-scale pipeline pays for itself in storage costs alone.
When to stay on JSON
Public APIs. Your consumers want to inspect responses with curl, your support team wants to see what was sent in a customer ticket, your DevOps want to grep logs. Binary formats break all of that. Use JSON until you have a measured reason not to.
Browser-server traffic. Browsers natively understand JSON via fetch().then(r => r.json()). To use MessagePack you need a library on the client, which adds bundle size that often eats the network savings.
Anywhere humans inspect the bytes. Configs, logs, test fixtures, error reports, API documentation. The decoded form is what humans need to see; if the file is binary, every tool needs a decoder step.
A useful rule of thumb: if you can paste the payload into the JSON validator on this site and read it, you are looking at a human-readable boundary, and JSON is probably right.
How it compares to Protobuf and CBOR
Protocol Buffers are the heavyweight cousin — even smaller, even faster, but they require a schema (.proto file) compiled into both ends. Choose Protobuf when you have a tightly controlled service mesh and you want versioned schemas as part of the contract. Choose MessagePack when you want schema-less serialization with the same data model as JSON.
CBOR (Concise Binary Object Representation, RFC 8949) is the IETF's standardised binary JSON replacement. Almost feature-equivalent to MessagePack, with slightly better support for streaming and tagged extensions. The choice between CBOR and MessagePack often comes down to library quality in your language — both are good formats, and the differences at this level are marginal.
Conclusion: MessagePack solves a real and narrow problem. Internal services, persisted blobs, streaming pipelines — go for it. Everything else — stay on JSON. The cost of debugging a binary format you cannot read is almost always higher than the cost of the bytes you save.