MessagePack Decoder

Decode MessagePack hex or base64 to JSON in your browser. 64-bit integers, binary, extensions and the timestamp type are tagged instead of silently mangled.

The interactive tool loads here when JavaScript runs.

About this tool

What is the MessagePack Decoder?

Paste MessagePack bytes as hex or base64 and get JSON back, decoded in your tab. MessagePack turns up wherever JSON felt too fat: Redis values, message queues, game network traffic, Fluentd logs, API payloads with a content-type nobody recognises. The sample is 39 bytes carrying a 4-key map with a timestamp and binary attached.

The decode is lossy only where JSON itself is the limit, and those edges are tagged instead of hidden. An integer past 2^53, which a JSON number would silently round, comes back as {"$int64": "..."} with the exact decimal. A bin payload becomes a $bytes hex preview rather than a mangled string. Extension types keep their type number under $ext, the spec's own timestamp extension (type -1) renders as an ISO 8601 $timestamp, and a map key that was not a string survives as "$key:...". Re-encode a naive decode and you get a different document; the tags exist so you can see exactly where that would happen.

The format is read as the msgpack.org spec defines it, from the one-byte fixint and fixstr forms to the 32-bit length variants, and the spec's one hole is honored: 0xc1 is marked "never used", so a payload containing it is refused by name rather than skipped.

  • Hex or base64 input, auto-detected, decoded entirely in your browser
  • Every lossy edge tagged: $int64 past 2^53, $bytes for bin, $ext with type numbers, $timestamp as ISO 8601, $key: for non-string map keys
  • All three spec timestamp formats (32, 64 and 96 bit) rendered as dates
  • Trailing-bytes warning for concatenated object streams
  • Refuses 0xc1 and truncated input by naming the byte, not by guessing past it
  • Copy or download the decoded JSON
Read the guide: How to Decode Binary Formats Without the Schema

Updated

How to use the MessagePack Decoder

  1. Get the bytes as hex or base64: redis-cli prints hex escapes for binary values, most logging and queue tooling prints base64, and a debugger gives you either.
  2. Paste and press Decode, or press Load a sample for an 18-byte map plus a timestamp and a bin field.
  3. Read the JSON. Anything tagged with a $ key is a value plain JSON could not carry: follow $int64 for exact big integers, $bytes for binary, $ext for application extensions, $timestamp for the spec's type -1.
  4. If a warning says bytes follow the first object, the payload is a stream of concatenated objects, which is common in logs and sockets; decode the rest by trimming the leading bytes.
  5. Copy or download the JSON for the ticket, the diff or the test fixture.

Worked examples

The classic 18 bytes

Input

82 a7 63 6f 6d 70 61 63 74 c3 a6 73 63 68 65 6d 61 00

Output

{"compact": true, "schema": 0}

0x82 is a map of 2, 0xa7 a 7-byte string, 0xc3 true, 0xa6 a 6-byte string, 0x00 the integer 0. The same document is 27 bytes as minified JSON; the 9 bytes saved are the length prefixes and quotes JSON spends.

The timestamp extension, rendered

Input

d6 ff 5e 0b e1 00

Output

{"$timestamp": "2020-01-01T00:00:00.000Z"}

0xd6 is fixext 4, 0xff the extension type -1, and the four payload bytes are 1577836800 seconds since the epoch. The spec assigns type -1 to timestamps; rendering it as ISO 8601 answers the "when" question the raw integer only implies.

A 64-bit integer JSON would corrupt

Input

cf ff ff ff ff ff ff ff ff

Output

{"$int64": "18446744073709551615"}

uint64's maximum. As a JavaScript number it would round to 18446744073709552000, a different value, which is how IDs silently corrupt in JSON pipelines. The tag keeps every digit as a string; integers at or below 2^53 stay plain numbers.

Binary stays binary

Input

c4 03 01 02 03

Output

{"$bytes": 3, "hex": "010203"}

0xc4 is bin 8: three raw bytes follow. Decoding them as a string would produce control characters; the preview gives the length and hex so a hash, a ciphertext or an embedded blob is recognisable at a glance.

Background and insight

MessagePack's trick is that small values pay almost nothing: integers from -32 to 127 are one byte, a map of up to 15 keys adds one byte, a string under 32 bytes adds one byte. The classic pair {"compact": true, "schema": 0} is 27 bytes as minified JSON and 18 bytes as MessagePack, and this page decodes exactly those 18 bytes as its test case. Larger values escalate through 8-, 16- and 32-bit length prefixes, capping strings, bins, arrays and maps at 2^32 - 1.

Unlike JSON, MessagePack distinguishes text from bytes: str is for UTF-8 strings, bin for raw byte arrays, a split that matters the moment a hash or ciphertext travels next to text. Integers are also wider, covering -(2^63) through 2^64 - 1, which is precisely the range JSON cannot promise: JavaScript numbers hold integers exactly only to 2^53, so anything above that is tagged $int64 here instead of rounded.

Extensions are the escape hatch: types 0 to 127 are application-defined, -1 to -128 are reserved by the spec, and the only predefined one is -1, timestamp, in three sizes. Timestamp 32 is plain seconds; timestamp 64 packs nanoseconds into the upper 30 bits and seconds into the lower 34, good through the year 2514; timestamp 96 is a 32-bit nanosecond field plus a full signed 64-bit seconds, covering times before 1970. All three render as ISO 8601 strings in the output, which is usually what the investigation needed.

Common use cases

  • Reading a Redis value that is not JSON

    Sessions, caches and queues often store MessagePack. Hex from redis-cli pastes straight in, and the $int64 tags show whether the user IDs were stored exactly.

  • Debugging a producer-consumer mismatch

    When two services disagree about a payload, decoding the actual bytes settles whether the number was sent as int or float, as string or bin, and whether a field is missing on the wire.

  • Inspecting Fluentd or game traffic captures

    Both ecosystems speak MessagePack natively and both concatenate objects back to back; the trailing-bytes warning tells you where one object ends and the next begins.

  • Verifying a serializer before it ships

    Encode in your language, paste the hex here, and check the types that round-trip badly: big integers, timestamps, binary fields and non-string map keys are all made visible.

  • Payloads too sensitive for an upload service

    The decode is local JavaScript; nothing is transmitted, so production payloads can be read without leaving the machine.

Tips and limitations

  • If the decode stops early with a trailing-bytes count, you have a stream: MessagePack has no document delimiter, so writers just concatenate. Decode, trim the reported bytes, repeat.
  • An error at a 0xc1 byte means the input is not MessagePack, or you are mid-stream: the spec marks 0xc1 as never used, so hitting it is proof of a framing or format mistake.
  • Integers up to 2^53 appear as plain JSON numbers; only larger ones get $int64. If you re-encode the decoded JSON, check those tagged values first, because they are the ones a JSON round trip would corrupt.
  • $ext values with positive types are application-defined; the spec says nothing about their contents. The hex preview is the starting point, and the owning codebase is the documentation.
  • A str that renders as garbage may legitimately be one: the spec notes string objects may contain invalid byte sequences, since validation is left to the receiver. If the field was really binary, the writer should have used bin.
  • MessagePack and CBOR look alike in a hex dump. CBOR's first byte for a small map is 0xa0 to 0xb7, MessagePack's is 0x80 to 0x8f; when a decode here looks wrong, try the CBOR decoder on this site before blaming the data.

Sources and further reading

  1. MessagePack specification, msgpack on GitHub. The format table (0xc1 never used), integer and length limits, str/bin split, ext and the timestamp type
  2. MessagePack, msgpack.org. The project home: implementations in every language, and the pitch the format makes

Frequently asked questions

How do I convert MessagePack to JSON without installing anything?

Paste the bytes here as hex or base64 and the JSON appears, decoded in your browser. Values JSON cannot represent exactly, 64-bit integers, binary, extensions and timestamps, come back tagged ($int64, $bytes, $ext, $timestamp) so the conversion is readable without being silently wrong.

Why do some numbers come back as {"$int64": "..."} strings?

MessagePack integers reach 2^64 - 1, but JavaScript numbers hold integers exactly only to 2^53. Beyond that a plain JSON number would round, turning one ID into a different one. The tag preserves the exact decimal as a string; smaller integers stay ordinary numbers.

What is the 0xc1 byte in MessagePack?

The one first-byte value the format never assigns: the spec's own table marks 0xc1 as never used. Any payload containing it at a position where a type byte is expected is either not MessagePack or being read from the wrong offset, so this decoder refuses it by name.

How are MessagePack timestamps encoded?

As extension type -1, in three sizes: 4 bytes of plain seconds (through 2106), 8 bytes with nanoseconds in the upper 30 bits and seconds in the lower 34 (through 2514), and 12 bytes with a 32-bit nanosecond field plus signed 64-bit seconds for dates before 1970. All three render here as ISO 8601.

What is the difference between str and bin in MessagePack?

str is for UTF-8 text, bin for raw bytes; JSON has no such split, which is why hashes and ciphertexts get mangled in JSON pipelines. This decoder renders str as a string and bin as a $bytes hex preview, so you can see when a writer used the wrong one.

Why is there leftover data after my MessagePack object?

MessagePack has no document separator, so streams are objects written back to back; Fluentd and most socket protocols do exactly this. The decoder reads one complete object and reports how many bytes remain, and you trim those off the front to decode the next one.

How much smaller than JSON is MessagePack really?

For small, key-heavy documents, roughly a third: the worked example is 27 bytes of minified JSON against 18 of MessagePack, saved from quotes and punctuation. For large strings or arrays of floats the gap shrinks, since the payload dominates; the format's wins are the one-byte small integers and length prefixes.

Is there an in-depth guide to the MessagePack Decoder?

Yes. “How to Decode Binary Formats Without the Schema” covers the background, how it works, common pitfalls and worked examples. Read the full guide.