CBOR / MessagePack Codec
Encode JSON to CBOR or MessagePack and decode binary payloads without losing types.
Input
Use $type envelopes for bytes, bigint, non-string map keys and other values JSON cannot hold.
Output
Related Tools
How to use
- 1.Choose CBOR or MessagePack, then Encode or Decode.
- 2.To encode, enter JSON or Extended JSON and select Encode; download the result as .cbor, .msgpack or .bin.
- 3.To decode, paste Hex or Base64 or choose a file, then select Decode.
- 4.Review the JSON, Type Tree, Hex and Stats tabs, and copy or download the result.
CBOR / MessagePack Codec
CBOR (RFC 8949) and MessagePack are binary serialization formats used by IoT devices, WebAuthn, COSE, Redis, Fluentd and many RPC protocols. They can carry values plain JSON cannot: raw bytes, integers up to 64 bits, undefined, NaN and Infinity, maps with numeric or binary keys, CBOR tags and simple values, and MessagePack extension types. This tool shows those values through Extended JSON envelopes instead of silently converting them, so encoding the JSON view again produces the same values. It reports the exact byte offset of truncated or malformed data, and compares the encoded size with minified JSON. Codec choice is always explicit because arbitrary CBOR and MessagePack bytes cannot be told apart reliably.
Extended JSON format
Values JSON cannot represent use single-object envelopes: bytes {"$type":"bytes","$hex":"0102"}; big integers {"$type":"bigint","$value":"18446744073709551615"}; maps with non-string or repeated keys {"$type":"map","$entries":[[1,"one"]]}; {"$type":"undefined"}; special numbers {"$type":"number","$value":"NaN"} (also Infinity, -Infinity, -0); CBOR tags {"$type":"cbor-tag","$tag":1,"$value":1700000000}; CBOR simple values {"$type":"cbor-simple","$value":16}; MessagePack extensions {"$type":"msgpack-ext","$ext":42,"$hex":"0102"}. Integers beyond 2^53−1 must use bigint so no precision is lost. Tags 2 and 3 around a byte string decode as big integers. An ordinary object whose "$type" is one of these reserved names must itself be written as a map envelope, for example {"$type":"map","$entries":[["$type","bytes"],["note","x"]]}.
Privacy
Encoding and decoding run entirely in your browser. Input, files and results are never uploaded or saved.
Frequently asked questions
- Can the tool detect whether bytes are CBOR or MessagePack?
- No. Arbitrary bytes are often valid in both formats, so you choose the codec explicitly.
- How are values JSON cannot hold shown?
- Byte strings, big integers, non-string map keys, undefined, NaN, CBOR tags and MessagePack extensions use documented $type envelopes, so the JSON view encodes back to the same values.
- Is the size difference a compression ratio?
- No. CBOR and MessagePack are serialization formats; the stats compare encoded bytes with minified JSON.
