JSON to MessagePack
Encode JSON to MessagePack in your browser. Output as base64 or hex, ready to drop into a WebSocket frame, a Redis value, or an HTTP body.
What is JSON to MessagePack?
You have a JSON config that's about to be sent over a tight WebSocket budget — MessagePack will shrink it 30-60% versus the same payload as JSON, and it does it without giving up the schemaless, "just an object" feel that makes JSON pleasant to work with. This page encodes whatever JSON you paste on the left into a msgpack byte stream on the right, served as base64 by default and switchable to hex with one click.
Encoding runs entirely in your browser using the official @msgpack/msgpack library, so the JSON never leaves the tab. Under the hood we parse the input with JSON.parse (the same parser the JSON RFC describes), hand the resulting object to msgpackEncode, and turn the returned Uint8Array into a transport-friendly string — base64 (per RFC 4648) or lowercase hex.
Use base64 when you're embedding the bytes in JSON, an HTTP header, or a database field. Use hex when you're comparing a sample byte-by-byte against the <a href="https://github.com/msgpack/msgpack/blob/master/spec.md" target="_blank" rel="noopener">msgpack wire spec</a> or a server log. Same bytes, different rendering.
How to Use the JSON to MessagePack Encoder
Three steps. The conversion runs automatically as you type — no button to click.
Paste JSON or Load the Sample
Drop your JSON into the left editor. Hit Sample JSON for a small order payload that exercises the cases that matter — strings, integers, floats, and a nested array. The encoder treats the input as the standard MessagePack type system: integers get the smallest fixint/int8/int16/int32/int64 form, floats become float64, strings get fixstr/str8/16/32 by length, arrays use fixarray/array16/32, and maps use fixmap/map16/32. Example input:
{
"orderId": "ORD-7421",
"items": [{ "sku": "SKU-101", "qty": 2 }],
"total": 89.50
}A 90-byte JSON like this typically encodes down to ~55 bytes of msgpack — a third smaller, before any gzip layer on top.
Toggle Hex or Base64
Output format defaults to base64 because that's what you usually paste into a config or send over the wire. Click Hex output to flip to lowercase hex if you're diffing against a server-side encoder or eyeballing the type bytes (e.g. 0x82 for a fixmap of 2). Toggle as often as you want — the underlying bytes are the same.
Copy and Ship
Hit Copy to put the output on your clipboard. Drop it straight into a Redis SET, a WebSocket text frame, an HTTP body with Content-Type: application/x-msgpack, or a Postgres bytea column (decode the base64 first). To go the other way, paste it into our MessagePack to JSON page.
When You'd Actually Use This
Shrink WebSocket Frames
Real-time apps with chatty per-second updates feel the size difference. A position update or order book tick that's 220 bytes as JSON drops to ~140 bytes as msgpack — across thousands of frames per second, that adds up. Convert one sample message here, paste the bytes into your test harness, and verify the receiver decodes it the same way.
Pack Cache Values
Caches like Redis charge you for every byte stored and every byte read. Encoding cached objects as msgpack instead of JSON-stringified text shaves storage and network on every hit. Use this page to spot-check what a given object will look like as bytes before you commit to the encoding in your serializer.
Send Typed Numbers
JSON has one numeric type and treats 42 the same as 42.0. MessagePack distinguishes between integer and float on the wire — useful when the receiver is a strongly-typed language like Go, Rust, or C# and you don't want to round-trip through a string. Paste a JSON number and inspect the type byte in hex output to confirm it encoded as an int, not a float.
Debug a Decoder
Got a service that "should" be msgpack but the consumer is choking on the bytes? Encode the same JSON here, compare your service's output to ours byte-for-byte in hex mode, and the divergence tells you exactly which field or type is wrong. The reference encoder follows the published spec precisely.
Common Questions
Does the JSON ever leave my browser?
No. The JSON is parsed by the browser's built-in JSON.parse, encoded by the @msgpack/msgpack library in client-side JavaScript, and rendered as base64 or hex in the right pane — there is no server call, no telemetry on the input, and nothing is logged. You can pop open DevTools and confirm the network tab stays quiet while you type. Safe for proprietary configs and customer data.
Why is the output bigger than I expected?
Two reasons usually. First, base64 inflates the byte count by about 33% — if you compare base64-msgpack to JSON text directly you're not comparing the actual wire size. Switch to hex (which inflates 2x) or, better, look at the byte length: in DevTools, atob(output).length tells you the true size. Second, msgpack only beats JSON when the data has lots of numbers, booleans, or repeated short strings. A blob that's 90% long unique strings will be roughly the same size in either format.
How are integers, floats, and big numbers handled?
JavaScript's JSON.parse turns every number into a 64-bit float, so by the time the data reaches the encoder we've already lost the int-vs-float distinction. The library is reasonable about this: a value that's integral and within safe-int range gets encoded as an int (using the smallest variant — fixint, int8, int16, int32, or int64). Anything else encodes as float64. If you need exact 64-bit ints (like Snowflake IDs), pass them through your JSON as strings, then convert on the receiver.
Can I encode binary blobs (like file bytes) with this?
Not directly through JSON, no — JSON has no bin type, so a Uint8Array round-trips through this UI as a base64 string and re-encodes as a msgpack str, not a bin. If you need real msgpack bin or ext types (the two big msgpack-only features), you have to build the object in code and call encode directly with a Uint8Array in place. The JSON pane is for the 90% case where your data is already JSON-shaped.
What's the difference between hex and base64 output?
They're two ways of writing the same bytes as text. Hex is two characters per byte (so 0x82 becomes the string "82") — useful for reading the spec's type bytes by eye. Base64 is four characters per three bytes per RFC 4648 — denser, and the standard way to embed binary in JSON, JWTs, or HTTP headers. Pick whichever fits where you're pasting the output.
Is msgpack actually faster than JSON, or just smaller?
Smaller is usually the bigger win. On encode/decode speed, modern JSON.parse is so optimized that msgpack ties or only wins by 10-20% in JS. The serialization win shows up downstream: smaller payloads mean less network time and less work for the receiver if it's in a language where parsing JSON costs more than parsing msgpack (looking at you, Python). Quick rule of thumb: pick msgpack if the bottleneck is bandwidth or storage; stick with JSON if it's readability and tooling.
Other MessagePack Tools
Encoding is one direction. These cover the rest of the round-trip: