Loading MessagePack Validator...
Please wait a moment

How to Check MessagePack Data

MessagePack is binary, so a payload cut off in a log, a string written with the wrong encoding or bytes mangled on the way through a text-only channel are hard to spot by eye. Paste the bytes here to find out whether a decoder will accept them, and if not, where it goes wrong.

Step 1

Paste or upload the MessagePack

Paste the bytes as Base64 or Hex (spaces, colons, commas, 0x prefixes, URL-safe Base64 and data: URIs are all fine), or upload a .msgpack or .bin file. The page works out which of the two you pasted. Sample loads a small map.

Example: the Sample in Base64

g6RuYW1lpEpvaG6jYWdlHqZhY3RpdmXD

These 24 bytes encode {"name":"John","age":30,"active":true}. In Hex they start 83 a4 6e 61 6d 65.

Step 2

Wait a moment for the check

The bytes are checked shortly after you stop typing. While new input is being checked, the result panel says Checking… instead of showing the verdict for what was there before.

Step 3

Read the verdict

Valid data shows how it was read, its size, what the top-level value is, how many values it holds and how deep it nests. Invalid data names the problem and the byte offset where it starts, or the line and column of a bad Base64 or Hex character.

Example: the verdict for the Sample

Valid MessagePack
Read as           Base64
Size              24 bytes
Top-level value   map with 3 keys
Values in total   7
Nesting depth     2
Step 4

Look at the decoded JSON

Below the verdict the same data is shown as JSON, with long integers written out in full. Copy or download it, or open the bytes in MessagePack to JSON if you only need the conversion.

What the check covers

Reported as invalid

  • Data that ends in the middle of a value
  • Lengths and counts larger than the bytes that follow
  • The byte 0xc1, which the format never uses
  • Text strings (str) that are not valid UTF-8
  • Timestamp extensions with a wrong length or too many nanoseconds
  • Leftover bytes after the value that are not MessagePack themselves
  • Nesting deeper than 1,000 levels (too deep to check here)

Warned about or not checked

  • Warning: the same text key twice in one map
  • Warning: map keys that are not text
  • Warning: several values back to back (a stream)
  • Not checked: whether the shortest encoding was used
  • Not checked: the meaning of application extension types

The rules come from the MessagePack specification. To convert in the other direction use JSON to MessagePack, and for a plain conversion with a Base64/Hex switch there is MessagePack to JSON.

Frequently Asked Questions

What makes MessagePack invalid?

Most broken data falls into a few groups. It is cut off, so a length or an array or map count promises more bytes than are there. It contains the byte 0xc1, the one value the format never uses. A text string (str) holds bytes that are not valid UTF-8. A timestamp extension (type -1) has the wrong length or more than 999999999 nanoseconds. Or there are bytes after the first complete value that are not MessagePack themselves. Each of these is reported with the byte offset where the trouble starts.

Why does it say "Not a single MessagePack value"?

The bytes hold two or more complete values one after another. That is how streams are written, for example by Fluentd or a logger that appends records, and a streaming unpacker reads them fine. A one-shot decoder such as msgpack.unpackb in Python or decode() in JavaScript expects exactly one value and stops with an extra data error. If you meant to send a list, wrap the values in an array before encoding.

My library accepts data this page rejects, or the other way round. Why?

Decoders differ at the edges. Python's msgpack refuses map keys that are not strings unless you pass strict_map_key=False, and JavaScript decoders only accept text and number keys, while the format itself allows any key type, so this page calls such data valid and warns about it. Some older decoders read invalid UTF-8 in a str without complaint, and most keep only the last value when a map repeats a key. The verdict here follows the MessagePack spec, with every byte read and none left over.

Are large integers shown exactly?

Yes. uint64 and int64 values are read as 64-bit integers, not as JavaScript numbers, so 18446744073709551615, -9223372036854775808 or an ID like 8901240544102066246 keep every digit, both in the details and in the decoded JSON. Text values such as "00501" or "14.50" stay text.

Can I paste JSON here?

No, the validator only checks encoded MessagePack, so JSON is reported as JSON rather than passed as valid. To get MessagePack from JSON, use JSON to MessagePack, then paste its Base64 output here if you want to check it.

Is my data uploaded anywhere?

No. The bytes are decoded and checked in your browser, nothing is sent to a server and nothing is kept, so a reload starts with an empty editor.