Skip to content
uencoder

MessagePack

MessagePack is an efficient binary serialization format, similar to JSON but more compact, with multilingual support, used for RPC and caching.

Purpose

To provide serialization that is smaller and faster than JSON for high-performance RPC and caching.

Mechanism

A single-byte type marker distinguishes nil, bool, integers, floats, strings, byte arrays, arrays, and maps. Small positive/negative integers use one-byte fixint; short strings use fixstr. It is not self-describing (a schema or convention is needed) but more compact than JSON.

Use cases

  • Redis serialized values
  • Thrift/MsgPack RPC
  • Game server communication
  • Embedded data exchange

Examples

  • Input
    {"a":1}
    Output
    81 a1 61 01

    A map with one pair

Common errors

The lack of a schema causes cross-language type mismatches
Use an IDL or explicit type conventions

Related terms

Related tools

References