JSON to MessagePack

Encode JSON into compact MessagePack bytes.

Runs in your browser Instant No sign-up
JSON input
MessagePack
Reverse

Paste, type or drop a file — output appears as you type.

Waiting for input
Processed locally · nothing is uploadedProcessed locally

How to use the MessagePack encoder

  1. Paste a JSON document into the left pane. The encoded bytes appear as you type.
  2. Output: Hex, Base64, Hex dump, C array, JS Uint8Array or Python bytes.
  3. Copy or Download the result. The status bar shows the encoded size next to the size of the minified JSON, so you can see how much MessagePack saves.

Example

{ "a": [1, 2] }

becomes the six bytes

81 a1 61 92 01 02

81 is a map with one entry, a1 61 the one-character string “a”, 92 an array of two items, and 01 02 the two fixints. The minified JSON is 11 bytes.

How values are encoded

  • null, true, false: c0, c3, c2.
  • Integers: positive fixint (0–127), negative fixint (-32 to -1), then uint8/16/32/64 or int8/16/32/64, whichever is smallest.
  • Floats: float32 when exact (1.5, 0.25, 1e2), float64 otherwise (0.1).
  • Strings: UTF-8, with fixstr, str8, str16 or str32 headers.
  • Arrays and objects: fixarray/array16/array32 and fixmap/map16/map32. Object keys keep their order.

The output is deterministic: the same JSON always gives the same bytes, which makes it easy to compare with what a library such as msgpack-python, @msgpack/msgpack or MessagePack-CSharp produces.

When it helps

Use it to build test fixtures for a service that speaks MessagePack, to check what a payload should look like on the wire, or to estimate how much smaller a format change would make your messages. Decode the result again with MessagePack to JSON, compare with the JSON to CBOR encoder, or tidy your input first with the JSON Formatter. To turn the hex into Base64 or other forms later, the Base64 tool is one click away.

How much smaller is it?

For typical API payloads MessagePack is often 10–30% smaller than minified JSON: numbers and booleans shrink to one to nine bytes, and short strings carry a single header byte instead of quotes. Text-heavy documents shrink less, because the strings themselves are stored as they are. The status bar shows both sizes for your own data.

Limits

MessagePack has no type for integers beyond 64 bits, so those are refused with an explanation. JSON has no binary type, so the encoder never produces bin or ext values.

Frequently asked questions

Does it pick the smallest encoding?

Yes. Every integer uses the shortest MessagePack type that holds it (positive or negative fixint, then 8, 16, 32 and 64-bit), strings use fixstr up to 31 bytes, and arrays and maps use their fix forms up to 15 items. Floats are written as float32 when that holds the value exactly, otherwise float64.

Are big integers exact?

Yes. The JSON is parsed without losing precision, so 18446744073709551615 becomes a uint64 and -9223372036854775808 an int64. Integers outside the 64-bit range can't be represented in MessagePack and give a clear error.

Why are 2 and 2.0 encoded differently?

A JSON number without a fraction or exponent, like 2, is encoded as an integer. A number written with a fraction or exponent, like 1.5 or 1e2, is encoded as a float, so the decoder on the other side gets the same type.

Which output formats are there?

Spaced hex (the default), Base64, an xxd-style hex dump, and ready-to-paste byte arrays for C, JavaScript (Uint8Array) and Python (bytes).

Is my JSON uploaded?

No. Encoding runs in your browser and nothing is sent anywhere.

Last updated