MessagePack Encode Online — JSON to MsgPack Bytes

Convert JSON to MessagePack binary in your browser. Output as base64 or hex, with live size comparison vs the equivalent JSON. 100% client-side — no upload, no account, no rate limits.

Click Encode to convert JSON to MessagePack base64 bytes.

Binary Serialization vs JSON

Binary serialization formats encode the same logical data as JSON — null, booleans, numbers, strings, arrays, objects — but using compact byte tags instead of decimal text. MessagePack is the most widely deployed JSON-equivalent binary format: a few hundred lines of spec, mature libraries in 50+ languages, and payloads that are typically 20–60% smaller than the JSON they replace.

JSON is unbeatable for human-readable APIs, log files, and config — anything you might want to cat, grep, or eyeball during an incident. The instant readability stops being a benefit when both sides of the wire are machines: an IoT sensor pushing telemetry over a metered cellular link, a Redis cache holding 10 million entries, or a mobile app refreshing data on a flaky 3G connection. That is where MessagePack pays for itself in bandwidth, parse time, and storage cost.

How to encode JSON to MessagePack — 4 steps

  1. Paste JSON. Paste any valid JSON document into the input panel above. Click Load Sample to try a representative IoT telemetry payload.
  2. Choose output format. Base64 is compact and transport-friendly (33% overhead); hex doubles the size but is easier to read byte-by-byte during debugging.
  3. Click Encode. The encoder walks the JSON tree, emits MessagePack type tags (fixstr, fixmap, uint8, etc.), and produces the binary buffer. Encode time is reported in milliseconds.
  4. Inspect and copy. Compare the MsgPack byte count to the JSON byte count to see the size saving for your shape, then copy the encoded payload.

Sample input and output

A small telemetry document encoded into MessagePack hex. Notice the type tags (0xa2 = fixstr length 2, 0x82 = fixmap with 2 entries, 0xcc = uint8) and how integers occupy one or two bytes instead of multi-character ASCII numerals.

# JSON input (54 bytes)
{"id":42,"name":"Atlas","online":true}

# MessagePack hex output (24 bytes — 56% smaller)
84 a2 69 64 2a a4 6e 61 6d 65 a5 41 74 6c 61 73
a6 6f 6e 6c 69 6e 65 c3

# Tag breakdown
84             fixmap, 4 entries
a2 69 64       fixstr "id"
2a             positive fixint 42
a4 6e 61 6d 65 fixstr "name"
a5 41 74 ...   fixstr "Atlas"
a6 6f 6e ...   fixstr "online"
c3             true

Compact Payloads

Integers, booleans, and short strings encode as 1–5 bytes instead of decimal text. Typical JSON-equivalent documents shrink by 30–50%.

Faster Parse

No string-to-number conversion, no quote escaping, no whitespace skipping — just type tags and length-prefixed bytes. Parsers run measurably faster.

Browser-Only

The encoder is plain JavaScript inside your tab. JSON containing API keys, customer IDs, or proprietary schemas never reaches our servers.

Common use cases

  • check_circleIoT telemetry over MQTT — every byte costs cellular money on metered links
  • check_circleRedis cache values — a 30% size reduction stretches the same RAM budget further
  • check_circleMobile-to-server APIs on flaky 3G/4G where reconnects and retries dominate latency
  • check_circlegRPC alternative when you want JSON ergonomics without protobuf .proto files
  • check_circleGame networking where tick rates of 30–60 Hz amplify any per-message overhead
  • check_circleBlockchain transaction payloads where on-chain bytes are paid for in gas
  • check_circleTime-series database row encoding (InfluxDB, Prometheus remote-write, Loki)
  • check_circleService-to-service queues (NATS, Kafka, RabbitMQ) handling millions of events per second

JSON vs MessagePack vs CBOR vs Protobuf vs BSON

FormatSchemaSize vs JSONSelf-describingBest for
JSONNone100% (baseline)YesPublic APIs, configs, logs
MessagePackNone~50–80%YesIoT, caches, mobile APIs
CBOR (RFC 8949)None~50–80%YesCOSE/CWT, IETF protocols
ProtobufRequired (.proto)~20–50%NogRPC, internal microservices
BSONNone~110% (often larger)YesMongoDB storage

Round-trip your data

Encode JSON to MessagePack, then decode back to verify lossless round-trip — or compare against the CBOR pair.

Frequently Asked Questions

What is MessagePack?

MessagePack is a compact binary serialization format that maps directly to JSON-style data — null, booleans, numbers, strings, arrays, and maps. Unlike JSON, it encodes integers and lengths as raw bytes instead of decimal text, so payloads are typically 20–60% smaller and parse faster on the wire. The official spec (msgpack.org) defines the type tags this encoder uses (fixstr, fixarray, uint8/16/32, etc.).

When should I use MessagePack instead of JSON?

Use MessagePack when bandwidth, storage, or parse cost matters and you control both sides of the wire: IoT devices on metered cellular links, MQTT payloads, Redis cache values, gRPC alternatives, mobile-to-server APIs, and game networking. Stick with JSON for public APIs, browser fetches, log files, and config — anywhere debuggability and tooling support matter more than raw bytes.

Why is the output base64 or hex if MessagePack is binary?

MessagePack is raw bytes with no text representation, so to display or paste it you need a text encoding. Base64 packs 3 bytes into 4 ASCII characters (33% overhead) and is the default for transport. Hex doubles the size (2 chars per byte) but is easier to read by hand for debugging. Toggle the format above the output panel.

How much smaller is MessagePack vs JSON?

It depends on the data. Documents heavy in numbers, booleans, and short strings shrink the most — often 30–50% smaller because integers occupy 1–5 bytes instead of decimal text. Documents dominated by long natural-language strings see almost no reduction since strings are stored verbatim. Try the sample above to see the live size delta against the equivalent JSON.

Does this encoder support every MessagePack type?

It covers the JSON-equivalent subset: nil (0xc0), false/true (0xc2/0xc3), positive and negative fixints, uint8/16/32, int8/16/32, float64, fixstr/str8/str16/str32, fixarray/array16/array32, and fixmap/map16/map32. uint64 and int64 outside 32-bit range fall back to float64. Bin types, Ext types, and Timestamp are decode-only — encoding from JSON does not need them because JSON has no native binary or extension representation.

Are floats encoded as float32 or float64?

Always float64 (0xcb). JavaScript numbers are IEEE 754 double-precision internally, so encoding everything as float64 round-trips perfectly without precision loss. If you need float32 to match a hand-tuned protocol from a C client, the Bytes column will read 5 bytes per number; you can patch the encoder to emit 0xca for values whose Math.fround() equals the original.

Does the data leave my browser?

No. The encoder is plain JavaScript running in your tab. Open DevTools → Network and click Encode — there are zero outbound requests. JSON containing API keys, customer IDs, or proprietary schemas never reaches our servers.

How do I decode the output?

Use the companion MessagePack Decode tool — paste the base64 or hex string and it round-trips back to JSON. From code, libraries like @msgpack/msgpack (JS), msgpack-python, msgpack-c, msgpack-rust, and msgpack-java will read the same bytes. Strip the base64/hex wrapper before passing to a binary parser.

MessagePack Encode Online — JSON to MessagePack Bytes (Base64 / Hex)