MessagePack: serializing JSON-like data as binary
MessagePack is a binary serialization format for values such as maps, arrays, strings, numbers, booleans, null, and binary data. It resembles JSON's value model but encodes values as typed bytes. It does not define your application's schema or field meanings, so producers and consumers need a separate contract.
MessagePack is a binary serialization format for values such as maps, arrays, strings, numbers, booleans, null, and binary data. It resembles JSON's value model but encodes values as typed bytes. It does not define your application's schema or field meanings, so producers and consumers need a separate contract.
What changes from JSON?
MessagePack supports distinct string and byte-array types, plus extension values containing an application-defined type code and bytes. A decoder can recover value types without a schema, but cannot infer field meaning, requiredness, units, or version rules. Document any application profile, such as allowed map-key types or extension codes.
Unlike JSON text, the bytes are not human-readable. If logs need readable data, record a filtered, decoded representation and avoid exposing secrets or personal data. MessagePack strings are UTF-8; binary values are byte arrays. Keep them distinct, especially across language libraries and older raw formats.
The format supports signed integers from −2^63 through unsigned 2^64−1, but not every runtime can represent that entire range identically. Check integer and decimal precision at both ends; consider strings or an agreed decimal representation for identifiers or amounts that cannot be preserved exactly.
Before migrating
Define how each JSON object or array maps to a MessagePack map or array, including field meanings and types.
Verify UTF-8 strings and binary values round-trip consistently in every language library.
Check 64-bit boundaries, large identifiers, and decimal precision.
Do not assign meaning to map order. If you hash serialized bytes, specify one deterministic key-ordering rule for every implementation.
Define extension codes, payloads, and whether unsupported extensions are rejected or passed through opaquely.
Pin supported format/library versions and any JSON-compatible mode.
Ensure diagnostic tools reveal only necessary fields.
Binary encoding may reduce transfer size, but real performance depends on data shape, encoder, compression, network, and parser. Measure your workload and weigh CPU and readability costs. This article reports no benchmark.
Sources
[MessagePack format specification](https://github.com/msgpack/msgpack/blob/master/spec.md)
[MessagePack project](https://msgpack.org/)