Purpose

MessagePack Ruby is a pure Ruby implementation of the MessagePack binary serialization format. MessagePack is an efficient binary serialization format that enables exchange of data among multiple languages like JSON, but is faster and smaller.

This implementation provides:

  • Pure Ruby implementation (no C extension required)

  • Full compatibility with the MessagePack specification

  • Support for custom extension types

  • Thread-safe factory pattern for packer/unpacker reuse

  • Streaming unpacker for incremental parsing

  • Comprehensive timestamp support with nanosecond precision

Getting started

Installation

Add this line to your application’s Gemfile:

gem 'messagepack'

And then execute:

bundle install

Or install it yourself as:

gem install messagepack

Quick start

require 'messagepack'

# Serialize data
data = { hello: "world", count: 42 }
binary = Messagepack.pack(data)

# Deserialize data
result = Messagepack.unpack(binary)
# => {"hello"=>"world", "count"=>42}

Core concepts

Learn more

External resources