Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
408 lines (362 sloc) 19.7 KB
<!DOCTYPE html>
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="MessagePack, msgpack, JSON, Binary JSON, Serializer, Serialization" />
<!--<meta name="description" content="" />-->
<link href='favicon.ico' rel='icon' type='image/x-icon'/>
<title>MessagePack: It's like JSON. but fast and small.</title>
<!--[if lt IE 9]><script type="text/javascript" src="" ></script><![endif]-->
<link media="all" rel="stylesheet" type="text/css" href="css/yuibase.css" />
<link media="all" rel="stylesheet" type="text/css" href="js/prettify/prettify.css" />
<link media="all" rel="stylesheet" type="text/css" href="css/all.css" />
<script type="text/javascript" src="js/all.js" ></script>
<script type="text/javascript" src="js/prettify/prettify.js" ></script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-17125377-1']);
_gaq.push(['_setDomainName', '']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
<body onload="prettyPrint();changeQuickStart('qs-ruby',document.getElementById('quickstart-default'));">
<!-- Facebook like button { -->
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); = id;
js.src = "//";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<!-- } Facebook like button -->
<header id="header">
<div id="headerwrap">
<h1 id="logo"><a href="/">MessagePack</a></h1>
<nav id="topnav">
<li><a href="">GitHub</a></li>
<li><a href="">Wiki</a></li>
<li><a href="">#msgpack</a></li>
<li><a href="">Spec</a></li>
<div id="desc">
<div id="descbody">
<img id="descimg" width="421" height="251" src="images/msgpack-json.png"/>
<div id="desctext">
<h2>It's like JSON. but fast and small.</h2>
<p>MessagePack is an efficient binary serialization format. It lets you exchange data among multiple languages like JSON but it's faster and smaller. For example, small integers (like flags or error code) are encoded into a single byte, and typical short strings only require an extra byte in addition to the strings themselves.</p>
<p>If you ever wished to use JSON for convenience (storing an image with metadata) but could not for technical reasons (encoding, size, speed...), MessagePack is a perfect replacement.</p>
<pre>&gt; require "msgpack" # gem install msgpack
&gt; msg = [1,2,3].to_msgpack #=&gt; "\x93\x01\x02\x03"
&gt; MessagePack.unpack(msg) #=&gt; [1,2,3]</pre>
<p>...and <a href="#crosslang">many other languages</a></p>
<div id="background">
<div id="content">
<h3>Happy Hackers :-)</h3>
<div class="tmset">
<a class="tmleft"></a>
<div class="tm">
<a class="tmlogo" href=""><img src="images/redis.png" alt="Redis" width="150" height="50" /></a>
<p class="tmtext">"Redis scripting has support for MessagePack because it is a fast and compact serialization format with a simple to implement specification. I liked it so much that I implemented a MessagePack C extension for Lua just to include it into Redis."</p>
<p class="tmauthor">Salvatore Sanfilippo, creator of Redis.</p>
<div class="tm">
<a class="tmlogo" href=""><img src="images/pinterest.png" alt="Pinterest" width="197" height="50" /></a>
<p class="tmtext">"MessagePack has been simply invaluable to us. We use MessagePack + Memcache to cache many of our feeds on Pinterest. These feeds are compressed and very quick to unpack thanks to MessagePack while Memcache gives us fast atomic pushes."</p>
<p class="tmauthor">Marty Weiner, Software Engineer.</p>
<div class="tm">
<a class="tmlogo" href=""><img src="images/saltstack.png" alt="Salt Stack" width="251" height="46" /></a>
<p class="tmtext">"I use MessagePack for all of the data serialization in Salt, it is fantastic! I tested quite a few serialization formats and MessagePack was dramatically faster and the data was always smaller. When I changed out pickles for MessagePack in Salt there was a speed increase of almost 3 fold across the board."</p>
<p class="tmauthor">Tom Hatch, author of Salt.</p>
<a class="tmright"></a>
<p class="tmcontribute">Also use MessagePack? <a href="">Waiting for your testimonial!</a></p>
<h3 id="crosslang">Implementation projects</h3>
<div class="qsset">
<ul class="qslist">
<li><a onclick="changeQuickStart('qs-ruby',this)" id="quickstart-default">Ruby</a></li>
<li><a onclick="changeQuickStart('qs-python',this)">Python</a></li>
<li><a onclick="changeQuickStart('qs-perl',this)">Perl</a></li>
<li><a onclick="changeQuickStart('qs-cpp',this)">C/C++</a></li>
<li><a onclick="changeQuickStart('qs-java',this)">Java</a></li>
<li><a onclick="changeQuickStart('qs-php',this)">PHP</a></li>
<li><a onclick="changeQuickStart('qs-javascript',this)">JavaScript</a></li>
<li><a onclick="changeQuickStart('qs-objective-c',this)">Objective-C</a></li>
<li><a onclick="changeQuickStart('qs-csharp',this)">C#</a></li>
<li><a onclick="changeQuickStart('qs-lua',this)">Lua</a></li>
<li><a onclick="changeQuickStart('qs-scala',this)">Scala</a></li>
<li><a onclick="changeQuickStart('qs-d',this)">D</a></li>
<li><a onclick="changeQuickStart('qs-haskell',this)">Haskell</a></li>
<li><a onclick="changeQuickStart('qs-erlang',this)">Erlang</a></li>
<li><a onclick="changeQuickStart('qs-ocaml',this)">OCaml</a></li>
<li><a onclick="changeQuickStart('qs-smalltalk',this)">Smalltalk</a></li>
<li><a onclick="changeQuickStart('qs-go',this)">Go</a></li>
<li><a onclick="changeQuickStart('qs-labview',this)">LabVIEW</a></li>
<div id="quickstart" class="qsholder"></div>
<div id="qs-ruby" class="qs">
<ul class="hlist">
<li><a href="">API Reference</a></li>
<li><a href="">RubyGems</a></li>
<pre class="prettyprint">gem install msgpack</pre>
<pre class="prettyprint">require "msgpack"
msg = [1,2,3].to_msgpack #=&gt; "\x93\x01\x02\x03"
MessagePack.unpack(msg) #=&gt; [1,2,3]</pre>
<p>Ruby implementation provides <a href="">streaming deserializer</a>.</p>
<div id="qs-python" class="qs">
<ul class="hlist">
<li><a href="">PyPI</a></li>
<pre class="prettyprint">easy_install msgpack-python</pre>
<pre class="prettyprint">import msgpack
msg = msgpack.packb([1,2,3]) #=&gt; "\x93\x01\x02\x03"
msgpack.unpackb(msg) #=&gt; [1,2,3]
<p>Python implementation provides streaming deserializer.</p>
<div id="qs-perl" class="qs">
<ul class="hlist">
<li><a href="">API Reference</a></li>
<li><a href="">CPAN</a></li>
<pre class="prettyprint">cpan Data::MessagePack</pre>
<pre class="prettyprint">use Data::MessagePack;
my $packed = Data::MessagePack-&gt;pack($dat);
my $unpacked = Data::MessagePack-&gt;unpack($dat);</pre>
<p>Perl implementation provides <a href="">streaming deserializer</a>.</p>
<div id="qs-cpp" class="qs">
<ul class="hlist">
<li><a href="">GitHub</a></li>
<li><a href="">Quick Start for C</a></li>
<li><a href="">Quick Start for C++</a></li>
<pre class="prettyprint">port install msgpack # MacPorts
brew install msgpack # Homebrew
apt-get install libmsgpack-dev # Ubuntu</pre>
<p>Or download <a href="">msgpack-0.5.7.tar.gz</a> and build it to install.</p>
<pre class="prettyprint">#include &lt;msgpack.hpp&gt;
struct myclass { std::vector<int> vec; MSGPACK_DEFINE(vec); };
msgpack::pack(buffer, vec);
msgpack::unpack(&amp;result,, buffer.size());</pre>
<div id="qs-java" class="qs">
<ul class="hlist">
<li><a href="">API Reference</a></li>
<li><a href="">Maven</a></li>
<li><a href="">GitHub</a></li>
<pre class="prettyprint">import org.msgpack.MessagePack;
MessagePack msgpack = new MessagePack();
byte[] bytes = msgpack.write(object);
MyClass object =, MyClass.class);</pre>
<p>Java implementation provides <a href="">streaming deserializer</a>, <a href="">dynamically typed objects</a>, <a href="">type conversion templates</a>, <a href="">dynamic template generators</a> and <a href="">annotations</a>.</p>
<p>Take a look at <a href="">test cases</a> for examples.</p>
<div id="qs-php" class="qs">
<ul class="hlist">
<li><a href="">Quick Start</a></li>
<pre class="prettyprint">git clone
cd msgpack-php
./configure &amp;&amp; make &amp;&amp; make install</pre>
<pre class="prettyprint">$data = array(0=&gt;1,1=&gt;2,2=&gt;3);
$msg = msgpack_pack($data);
$data = msgpack_unpack($msg);</pre>
<div id="qs-javascript" class="qs">
<ul class="hlist">
<li><a href="">GitHub</a></li>
<li><a href="">msgpack.js</a></li>
<pre class="prettyprint">var myByteArray = msgpack.pack(myObject);
myObject = msgpack.unpack(myByteArray);</pre>
<p>Licensed under MIT license.</p>
<div id="qs-objective-c" class="qs">
<ul class="hlist">
<li><a href="">GitHub</a></li>
<pre class="prettyprint">
#import "MessagePack.h"
NSData* packed = [someArray messagePack];
NSArray* someArray = [packed messagePackParse];
<div id="qs-csharp" class="qs">
<ul class="hlist">
<li><a href="">GitHub</a></li>
<li><a href="">Wiki</a></li>
<pre class="prettyprint">using MsgPack.Serialization;</pre>
<pre class="prettyprint">var serializer = MessagePackSerializer.Create&lt;Foo&gt;();
serializer.Pack(foo, stream);
stream.Position = 0;
var value = serializer.Unpack(stream);</pre>
<p>You can also use C#(CLI) implementation for any other CLI (Common Language Infrastructure) languages such as Visual Basic.<br />
CLI implementation also provides streaming deserializer, some level of dynamic typing, and annotations. See <a href="">Wiki</a> for details.</p>
<div id="qs-lua" class="qs">
Coming soon...
<ul class="hlist">
<li><a href="">GitHub</a></li>
<pre class="prettyprint">require "msgpack"
data = msgpack.pack(1, 2, 3, "strings", {"a", "r", "r", "a", "y", "s"},
{t = "a", b = "l", e = "s"; 1, 2, 3, 4})
a, b, c = msgpack.unpack(msgpack.pack(1, 2, 3))</pre>
<div id="qs-scala" class="qs">
<ul class="hlist">
<li><a href="">Quick Start</a></li>
<div id="qs-d" class="qs">
<ul class="hlist">
<li><a href="">API Reference</a></li>
<li><a href="">GitHub</a></li>
<p>msgpack-d is only one file. Please add msgpack.d to your project.</p>
<pre class="prettyprint">import msgpack;
Tuple!(uint, string) receive, send = tuple(2012. "Hello D!");
auto serialized = pack(send);
unpack(serialized, receive);
assert(send == recieve);</pre>
<p>D implementation also provides streaming deserializer.</p>
<div id="qs-haskell" class="qs">
<ul class="hlist">
<li><a href="">API Reference</a></li>
<li><a href="">hackageDB</a></li>
<li><a href="">Quick Start</a></li>
<pre class="prettyprint">import Data.MessagePack
main = do
let bs = pack (1 :: Int, 3.14 :: Double, "Hello, MessagePack!")
print bs
print (unpack bs :: (Int, Double, String))
<div id="qs-erlang" class="qs">
<ul class="hlist">
<li><a href="">API Reference</a></li>
<li><a href="">Repository</a></li>
<p>Write into your <a href="">rebar</a>.config:</p>
<pre class="prettyprint">{deps, [
{msgpack, ".*",
{git, "git://", "HEAD"}}
<pre class="prettyprint">{Spam, _} = msgpack:pack(Ham),
Ham = msgpack:unpack(Spam).</pre>
<div id="qs-ocaml" class="qs">
<pre class="prettyprint">
$ git clone
$ cd msgpack-ocaml
$ omake
$ omake install</pre>
<pre class="prettyprint">
<a href="">This library is mathematically proven!</a>
<div id="qs-smalltalk" class="qs">
<ul class="hlist">
<li><a href="">GitHub</a></li>
<pre class="prettyprint">
map := Dictionary new.
map at: 'someArray' asByteArray put: #(1 2.2 #[3 4 5]).
packed := map messagePacked.
(Object fromMessagePack: packed) inspect.
<div id="qs-go" class="qs">
Coming soon...
<div id="qs-labview" class="qs">
<ul class="hlist">
<li><a href="">SourceForge</a></li>
Installable through the VI Package Manager using one of the compiled versions on the
<a href="">downloads page</a>
<h3>Related projects</h3>
<div class="paragraphs">
<h4><a href="">ZeroRPC</a> by DotCloud</h4>
<p>zerorpc is a flexible RPC implementation based on zeromq and messagepack. Service APIs exposed with zerorpc are called "zeroservices".</p>
<h4><a href="">pficommon</a> by Preferred Infrastructure, Inc.</h4>
<p>General purpose C++ library for Preferred Infrastructure, Inc. It includes MessagePack-RPC implementation for C++</p>
<h4><a href="">MessagePack-RPC for Ruby</a></h4>
<p>MessagePack-RPC implementation for Ruby</p>
<h4><a href="">MessagePack-RPC for Java</a></h4>
<p>MessagePack-RPC implementation for Java</p>
<h4><a href="">MessagePack-RPC for Haskell</a></h4>
<p>MessagePack-RPC implementation for Haskell</p>
<h4><a href="">MessagePack-RPC for Python</a></h4>
<p>MessagePack-RPC implementation for Python</p>
<footer id="footer">
<div id="footerbody" class="paragraphs">
<div id="social">
<iframe src=""
allowtransparency="true" frameborder="0" scrolling="0" width="132px" height="20px"></iframe>
<a href="" class="twitter-share-button" data-hashtags="msgpack">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);;js.src="//";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
<div class="fb-like" data-href="" data-send="false" data-layout="button_count" data-width="120" data-show-faces="false"></div>
<div id="thanks">
<p id="sponsor"><a href="">Sponsored by Treasure Data, Inc. <img src="images/td-icon.png" width="20" height="20" /></a></p>
<p>Copyright &copy; 2008-2012 FURUHASHI Sadayuki</p>
Something went wrong with that request. Please try again.