TXT · Text & Data tools

JSON to CBOR

Output encoding
JSON
CBOR bytes
CBORformat0 Bwritten0 Bas JSON0chars out
Open the full binary format decoder with every format and the encoder

Shareable link

Settings are written to the URL as you change them. Nothing differs from the defaults yet.

Encode a payload

Paste JSON and the CBOR bytes appear as hex or Base64. Integers take the smallest head that fits, text strings are major type 3, and containers state their element count.

{"a": 1, "b": [2, 3]} becomes a26161016162820203, 9 bytes. The leading a2 is a 2-entry map and nothing else in the stream needs a separator.

CBOR against MessagePack

The two formats sit within a byte or two of each other for most payloads. CBOR is the one written into IETF specifications, so it is what COSE, WebAuthn, and most constrained-device protocols expect on the wire. MessagePack has wider library support in application code.

Pick by what reads the bytes on the other end, not by size. The comparison under the output shows both counts when there is a real difference.

Canonical encoding

Deterministic CBOR requires shortest-form integers and map keys sorted by their encoded bytes. This encoder writes shortest-form integers but preserves the key order of the JSON input, since reordering silently would change any hash or signature computed over the result. Sort the keys in the source when a canonical form is needed.

Frequently Asked Questions

Definite. Every array, map, and string states its length up front, which is the form embedded parsers and COSE implementations expect.

No. Fractional numbers are written as float 64, so a value round-trips to exactly what the JSON held.

No. A tag says how to read a value, and JSON has no way to mark that intent. Tagged payloads decode correctly on the Decode side.

Pages locked to one format

Full Binary Format Decoder tool

Explore Our Tools

Browse all tools