CBOR Encoder - Encode JSON, YAML, XML or CSV to CBOR
Turn JSON, YAML, XML, CSV or plain text into CBOR binary and copy it as Base64 or Hex, or download a .cbor file.
How to Encode Data to CBOR
Pick the input format
CBOR (Concise Binary Object Representation) holds the same kinds of values as JSON, so most data you already have can go straight in. This page is for when it isn't JSON yet: a YAML config, an XML export, a CSV sheet or a single line of text. If you only ever start from JSON, the JSON to CBOR converter does the same job with a few more checks for JSON-specific mistakes.
Example: JSON input
{ "name": "Maeve", "age": 30, "active": true }
Read the encoded output
Encoding starts half a second after you stop typing. The bytes follow RFC 8949, using the shortest form for every integer, length and float.
Example: the JSON above as CBOR (Base64)
o2RuYW1lZU1hZXZlY2FnZRgeZmFjdGl2ZfU=
That is 26 bytes, against 52 for the JSON with its indentation.
Choose Base64 or Hex
CBOR is binary, so the page shows it as text you can copy. Switching between the two re-draws the same bytes.
Copy or download
Frequently Asked Questions
Which input formats can I encode?
Five: JSON, YAML, XML, CSV and plain text. Pick the tab that matches what you paste. YAML maps and lists become CBOR maps and arrays, and a file with several --- documents becomes one array. XML is read with element names as keys and text as strings (attributes go under _attributes, text under _text). A CSV becomes an array of maps, one per row, keyed by the header row. Plain text becomes a single CBOR text string, unless it is just a number, true, false or null.
What happens to long numbers like 8901240544102066246?
They are written as real CBOR integers with every digit, in JSON, YAML, CSV and plain text alike. Anything that fits 64 bits (up to 18446744073709551615, down to -9223372036854775808) uses the normal integer types, and anything bigger becomes a bignum (tag 2 or 3). Numbers with a decimal point or exponent, such as 14.50, become binary floats in the smallest width that holds them exactly, so they read back as 14.5. Text with leading zeros, like a 00501 zip code in a CSV or YAML file, stays text so the zeros are not lost.
How are CSV cells typed?
Only when nothing would change. A cell that is a plain number becomes a number, true and false (or TRUE and FALSE) become booleans, and an empty cell becomes null. Everything else, including 00501, 1,234 or a date, stays a text string exactly as it was written.
How do I read the CBOR back?
Download the .cbor file, or copy the Base64 or Hex text and turn it back into bytes, then hand it to any CBOR library: cbor2 in Python, cbor-x in JavaScript, fxamacker/cbor in Go, jackson-dataformat-cbor in Java or ciborium in Rust. To check the result without writing code, paste the Base64 into the CBOR to JSON converter on this site.
Is the output deterministic?
Every integer, length and float uses its shortest form and all lengths are definite, which is the preferred serialization in RFC 8949. Map keys stay in the order you wrote them instead of being sorted, so if you need the section 4.2 deterministic encoding for signing or hashing, sort the keys in your input first.
Is my data uploaded anywhere?
No. The encoding runs in your browser, so what you paste or upload is not sent to our server, and nothing is kept: a reload starts with an empty editor. Very large inputs are limited only by your device, though a file with tens of thousands of records can take a few seconds.
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 Decoder
Decode CBOR binary to JSON, YAML, XML, CSV formats with Base64 and Hex input
CBOR Formatter
Format and beautify CBOR diagnostic notation
CBOR Validator
Validate CBOR binary data structure and integrity