CBOR Converter
Convert between JSON and CBOR (RFC 8949).
Overview
The CBOR converter translates between JSON and Concise Binary Object Representation as specified in RFC 8949. Paste JSON to get CBOR bytes (hex or base64), or paste CBOR to recover the document as readable JSON.
CBOR shows up in IoT firmware, WebAuthn assertions, COSE-signed messages, and any protocol where size matters more than human readability. Embedded developers, security engineers, and protocol implementers reach for a cbor decoder when inspecting a captured payload or producing test vectors for a constrained device.
How it works
CBOR is a binary serialization defined by RFC 8949. Each item begins with an initial byte whose top three bits indicate the major type (unsigned int, negative int, byte string, text string, array, map, tag, or simple/float) and whose bottom five bits give the additional info — usually the length or value, with overflow extension bytes for larger magnitudes.
The converter handles all eight major types, indefinite-length streams, half/single/double precision floats, and the common tags for date/time (0, 1), bignum (2, 3), and decimal fractions (4). CBOR types without a JSON peer (byte strings, tags) are rendered using Extended JSON markers so the round trip is lossless.
Examples
JSON in: {"a":1,"b":[2,3]}
CBOR out: a2 61 61 01 61 62 82 02 03
JSON in: [1, 2.5, "hi"]
CBOR out: 83 01 fb 4004 0000 0000 0000 62 68 69
CBOR in (hex): a16568656c6c6f65776f726c64
JSON out: {"hello":"world"}
FAQ
Why use CBOR instead of JSON?
CBOR encodes the same data model in fewer bytes, parses faster, and supports binary data natively without base64 wrapping. RFC 8949 is the basis for COSE, CWT, WebAuthn attestations, and many IoT protocols.
Does it handle CBOR tags like timestamps?
Yes. Tag 0 (RFC 3339 string) and tag 1 (epoch seconds) decode to ISO 8601 strings. Bignum tags 2 and 3 decode to numeric strings to preserve precision beyond 53 bits.
Can it produce deterministic CBOR for COSE signing?
Output uses canonical encoding rules: shortest-form integer encoding, definite-length items, and sorted map keys. That matches the deterministic profile used by COSE.