CBOR (Concise Binary Object Representation) is a binary serialization format defined by RFC 8949 that encodes the same data model as JSON in far fewer bytes. It is the wire format for WebAuthn credential payloads, COSE signed messages, CoAP and a wide range of IoT protocols. This tool takes ordinary JSON and produces the equivalent CBOR as a hex dump and base64 string, so you can build and inspect those payloads by hand.
How it works
Every CBOR item starts with a head byte whose top 3 bits encode the major type and whose low 5 bits encode the additional information:
- Integers (major types
0and1) are written with the smallest head that fits the value — inline for0–23, then 1, 2, 4 or 8 following bytes. - Text strings (major type
3) are UTF-8 encoded with a length prefix. - Arrays (major type
4) and maps (major type5) write their element count, then each item — recursively. true,falseandnullare the single bytes0xf5,0xf4and0xf6, and non-integer numbers are written as an IEEE 754 double after the0xfbhead byte.
The encoder walks your parsed JSON value following exactly these rules, producing definite-length output that any conformant CBOR decoder can read back.
Example
The JSON {"a":1,"b":[2,3]} encodes to the hex a2 61 61 01 61 62 82 02 03:
a2 map of 2 pairs
61 61 text "a"
01 unsigned int 1
61 62 text "b"
82 02 03 array [2, 3]
That is 9 CBOR bytes versus 17 bytes of JSON text. The tool reports this comparison for any input so you can see the savings, and everything runs locally in your browser.