Loading CBOR Decoder...
Please wait a moment

How to Decode CBOR Binary Data - Step by Step Guide

Step 1

Input your CBOR data

CBOR (Concise Binary Object Representation, RFC 8949) is binary, so it usually reaches you already written out as Base64 or hex: in a log line, an MQTT message dump from an IoT device, or a column in a database. Any of these works:

•
Select input format: Base64 (the default, URL-safe and unpadded forms are fine) or Hex (spaces, commas, colons and 0x prefixes are fine)
•
Paste directly: drop the string into the input editor; surrounding quotes or a data: prefix can stay
•
Upload a file: click Upload and pick a binary .cbor or .bin file, or a .txt file that holds Base64 or Hex
•
Try the sample: click Sample to load the example below

Example: CBOR Input (Base64)

Here's what encoded CBOR binary data looks like:

o2RuYW1lZU1hZXZlY2FnZRgeZmFjdGl2ZfU=
Step 2

Let it decode

The decoded data appears on the right a moment after you stop typing. Damaged or cut-off data gets a plain error instead of a partial result. The bytes are read by a small CBOR reader on this page that follows RFC 8949:

•
Exact integers: uint64, int64 and bignum values keep every digit, so an ID like 8901240544102066246 is never rounded
•
Types kept apart: text stays text ("00501" keeps its zeros), floats stay floats, byte strings are shown as Base64
•
Plain errors: cut-off values, reserved bytes and text that isn't valid UTF-8 are reported instead of showing half a result
•
Notes when something changes: if a value has to be written differently, such as a tag or NaN, a short note above the output says what was done

Example: Decoded JSON Output

The same CBOR, now decoded as readable JSON:

{
  "name": "Maeve",
  "age": 30,
  "active": true
}
Step 3

Choose the output format

Switch between JSON, YAML, XML, CSV and Text above the output. All five are written from the same decoded data, so numbers and text come out the same in each.

•
JSON (default): the closest match to CBOR, ready for APIs, tests and JavaScript code
•
YAML: the easiest to read by eye, useful for big nested payloads and config-style data
•
XML: for systems that only take XML; the data sits under one <root> element
•
CSV: for a list of records you want in a spreadsheet, one row per record
•
Text: shows a single string or number without quotes; maps and lists are shown as JSON
Step 4

Copy or download the result

Copy the output or download it as decoded.json, decoded.yaml, decoded.xml, decoded.csv or decoded.txt.

•
Copy: puts the output on your clipboard for your code editor, a terminal or a ticket
•
Download: saves the output in the format you picked, as a UTF-8 file
•
Further processing: use the result with the JSON Formatter, the YAML Formatter or JSON to Table. If you only need JSON, CBOR to JSON does just that.

Frequently Asked Questions

Why decode CBOR to YAML, XML or CSV instead of JSON?

Pick the format for where the data is going next. JSON is the closest match to CBOR and the default. YAML is easier to read when you are scanning a big sensor payload or a COSE header by eye. XML helps when the data has to be fed to an older system or an XSLT step. CSV is handy when the CBOR is a list of similar records, such as readings from many devices, and you want them in a spreadsheet. Text shows a lone string or number without quotes.

How do CBOR values look in each output format?

Integers keep every digit in all formats, including uint64, int64 and bignums (tags 2 and 3): 8901240544102066246 stays 8901240544102066246. Byte strings become Base64 text. In XML every value is element text, a list under a key becomes that element repeated, and a list at the top level is wrapped in <item> elements so the document has one root. Keys that are not valid XML names get their odd characters replaced with an underscore, and a note says so. In CSV, null becomes an empty cell and nested maps or lists are written as compact JSON inside the cell.

What shape does my CBOR need for CSV output?

CSV works best for a list of maps: each map becomes one row and the columns are every key that appears in any row, in the order they first show up, so a key missing from one record just leaves that cell empty. A single map becomes one row, and a list of plain values becomes one column called value. An empty list has no rows, so the page tells you instead of writing an empty file. If you open the CSV in Excel, import ID columns as text, because Excel rounds numbers longer than 15 digits.

What happens to CBOR tags, dates and special values?

Date strings (tag 0) are kept as written and epoch dates (tag 1) become ISO 8601 text in UTC. Bignums are written as plain integers. Any other tag is shown as a small map with tag and value. CBOR undefined becomes null, and NaN or Infinity become the text NaN or Infinity. Whenever one of these changes happens, a note above the output tells you.

Why does the decoder say my data is cut off or in the wrong format?

A cut-off message means the bytes end in the middle of a value, which usually happens when a Base64 string was not copied in full. A bad character in Base64 or Hex is pointed out by line and column. If you paste hex while Base64 is selected, or the other way round, the page asks you to switch rather than showing a run of junk values. Pasting JSON or XML by mistake gets its own message too.

Can I upload a .cbor file?

Yes. A binary .cbor, .cbr or .bin file is read byte for byte. A text file that holds Base64 or Hex, for example one saved from a log, is loaded as that text instead of being encoded again. Several CBOR values stored back to back in one file are shown as a list. If the file is empty or cannot be read, your current input is left alone and a short message explains why.

Does my CBOR leave the browser?

No. The bytes are decoded by JavaScript on this page and nothing you paste or upload is sent to a server. The decoder is free and needs no account.