JSON ↔ MessagePack
Encode JSON to MessagePack bytes (shown as hex) or decode MessagePack bytes back to JSON. Covers nil/bool/int/float64/str/array/map: no bin, ext, or timestamp extension types. Runs on your device.
Runs on your device. The file is never uploaded.
JSON to MessagePack packs a document and prints the bytes as hex, or reads raw bytes back into JSON when mode is decode. Integers take the shortest form available: 0 to 127 and negatives down to minus 32 cost one byte. Hitting a bin, ext or timestamp marker while decoding stops the run, naming the byte in hex.
Questions
What does this tool convert?
JSON to MessagePack and back. Encode is the default and gives you the packed bytes as space-separated hex; decode reads the raw bytes of a file and prints JSON with 2-space indentation. MessagePack is a binary format that stores the same values as JSON in fewer bytes.
How do I feed the hex back into decode?
Turn it into bytes first with the From hexdump tool, which writes a .bin file from a run of hex pairs and accepts either a bare hex string or a full dump. Decode mode reads bytes, not text, so dropping the hex file straight back in gives you an error or nonsense rather than your JSON.
Which MessagePack types are covered?
nil, booleans, integers, 64-bit floats, strings, arrays and maps. The bin, ext and timestamp families are not implemented, and hitting one while decoding stops with a message naming the marker byte. That set covers everything JSON can express, which is what a JSON converter needs.
How compact is the encoding?
Integers use the smallest form available: values 0 to 127 take a single byte, then 8, 16 and 32-bit forms, with the same ladder for negatives down to minus 32 in one byte. Short strings up to 31 bytes and small arrays and maps up to 15 entries also pack their length into the first byte.
Why do my bytes differ from another library?
Two likely reasons. Map keys are written in the order they appear in your JSON rather than sorted, and any number that is not a safe whole integer is written as a 64-bit float rather than a narrower one. Byte arrays are also unavailable here, so a library that uses bin will not match.
Does anything get sent to a server?
No. Packing and unpacking happen in a Web Worker in this tab, with nothing sent to a server. The only limit is nesting depth, which is refused past 300 levels rather than risking a stack overflow. Everything else depends on your own memory, since the whole file is held in the tab while it works.