CBOR to JSON

Decode CBOR data items into readable JSON.

Runs in your browser Instant No sign-up
Input
Indent
CBOR (hex or Base64)
JSON
Reverse

Paste, type or drop a file — output appears as you type.

Waiting for input
Processed locally · nothing is uploadedProcessed locally

How to use the CBOR decoder

  1. Paste CBOR as hex (a6 62 69 64 …) or Base64 into the left pane.
  2. Input: Detect, Hex or Base64.
  3. Indent: choose 2 or 4 spaces, tabs, or minified JSON.
  4. Under More options: Values (First value or All, for a sequence of items) and Bytes as (Hex string or Tagged).

Example

The RFC 8949 example of an indefinite-length map

bf 61 61 01 61 62 9f 02 03 ff ff

decodes to

{ "a": 1, "b": [2, 3] }

The bf opens a map of unknown length, 9f … ff is an indefinite array, and the final ff closes the map.

What it understands

All eight major types: unsigned and negative integers (exact up to 64 bits, and beyond through bignum tags), byte strings, UTF-8 text strings, arrays, maps, tags and simple values. Floats come in half, single and double precision. undefined becomes null with a warning, and simple values other than false, true, null and undefined appear as {"$simple": n}. Every example in Appendix A of RFC 8949 is part of the test suite.

Map keys that are not strings, such as the integer keys COSE uses ({1: 2, 3: -7}), are written as JSON text keys, with a warning that the original type was not a string.

When it helps

Decoding a WebAuthn attestationObject, a COSE key, or a sensor reading usually starts with a Base64 or hex blob from a log or a debugger. Paste it here, then explore the JSON in the JSON Viewer. If the blob came Base64url-encoded inside a JWT-style token, the JWT Decoder and the Base64 tool help get at the bytes first. To build CBOR from JSON, use JSON to CBOR; for the similar MessagePack format, see MessagePack to JSON.

Limits and safety

Corrupt input gives an error with the byte offset rather than a partial result. A length or count larger than the remaining bytes is refused before any memory is allocated, and nesting deeper than 500 levels stops with a message, so a malicious payload can’t hang the tab. NaN and Infinity become null, since JSON can’t represent them.

Frequently asked questions

Where would I see CBOR?

WebAuthn and passkeys (attestation objects and authenticator data), COSE keys and signatures, EU Digital COVID and other health certificates, CoAP and IoT devices, and some blockchain formats. It is the binary counterpart of JSON defined in RFC 8949.

Are tags and bignums supported?

Yes. Tag 0 date strings stay strings, tag 1 epoch times become ISO 8601 dates, tags 2 and 3 bignums become exact integers, and the self-describe tag 55799 is unwrapped. Other tags are shown as {"$tag": n, "value": …} so nothing is lost.

What about indefinite-length items and half floats?

Both work. Indefinite-length byte strings, text strings, arrays and maps are read until their break byte, and 16-bit half floats are decoded exactly, like the other float sizes.

Why is a value shown as a hex string?

It is a CBOR byte string. JSON has no binary type, so bytes are written as hex; set Bytes as to Tagged to get {"$bin": "…"} instead and tell them apart from text.

Is my data uploaded?

No. Everything is decoded in your browser.

Last updated