How to Decode CBOR Binary Data - Step by Step Guide
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:
Example: CBOR Input (Base64)
Here's what encoded CBOR binary data looks like:
o2RuYW1lZU1hZXZlY2FnZRgeZmFjdGl2ZfU=
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:
Example: Decoded JSON Output
The same CBOR, now decoded as readable JSON:
{ "name": "Maeve", "age": 30, "active": true }
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.
Copy or download the result
Copy the output or download it as decoded.json, decoded.yaml, decoded.xml, decoded.csv or decoded.txt.
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.
Related Tools
CBOR to JSON
Convert CBOR binary data to JSON format with Base64 and Hex support
JSON to CBOR
Convert JSON data to CBOR binary format
CBOR Fixer
Fix broken CBOR data automatically, repair malformed binary object representations and structural errors
CBOR Encoder
Encode JSON, YAML, XML, CSV to CBOR binary format with Base64 and Hex output
CBOR Formatter
Format and beautify CBOR diagnostic notation
CBOR Validator
Validate CBOR binary data structure and integrity