CBOR Binary Data Decoder

CBOR Decoder

Use this CBOR Decoder to convert hexadecimal Concise Binary Object Representation data into readable values. Inspect unsigned and negative integers, byte strings, UTF-8 text, arrays, maps, semantic tags, booleans, null, floating-point values and indefinite-length CBOR structures.

✓ Major Types 0–7 ✓ Arrays & Maps ✓ UTF-8 Text ✓ Semantic Tags ✓ Indefinite Length
HEX
Decode CBOR Hex
● Ready
Enter hexadecimal CBOR bytes. Spaces, commas, colons, hyphens and 0x prefixes are accepted. Continuous hexadecimal input also works.
Decoder scope: the tool validates and decodes one complete CBOR data item. Semantic tags are reported with their numeric tag value and enclosed item; a tag does not automatically cause application-specific transformation. The decoder also distinguishes malformed CBOR from structurally valid values.
CBOR Decode Result Decoded
Readable CBOR Value
Input Bytes
Top Major Type
Total Items
Maximum Depth
Arrays
Maps
Tags
Indefinite Items
# Path Offset Major Type Decoded Type Value / Length Encoded Bytes
Byte-Level Decode Breakdown -
Readable CBOR Decode
-

What Is a CBOR Decoder?

A CBOR Decoder converts the binary Concise Binary Object Representation format into values that are easier to inspect. CBOR is designed for compact binary serialization while still supporting integers, binary data, text, arrays, maps, floating-point numbers, semantic tags and other structured values.

This decoder accepts hexadecimal bytes and follows the structure defined by RFC 8949 rather than treating CBOR as JSON with a different byte encoding. That distinction matters because CBOR supports values that JSON does not, including byte strings, integer map keys, semantic tags, undefined, simple values and indefinite-length containers. :contentReference[oaicite:1]{index=1}

CBOR Initial Byte Format

Every CBOR data item starts with an initial byte. The upper three bits select one of eight major types while the lower five bits contain additional information.

Initial Byte: MMM AAAAA MMM = 3-bit major type AAAAA = 5-bit additional information

For small arguments from 0 through 23, the additional-information field contains the argument directly. Larger arguments use extra bytes.

CBOR Major Types

Major Type Meaning Content
0Unsigned IntegerArgument is the value
1Negative IntegerValue = −1 − argument
2Byte StringBinary bytes
3Text StringUTF-8 text
4ArrayOrdered CBOR items
5MapKey/value item pairs
6Semantic TagTag number + one enclosed item
7Simple / FloatBooleans, null, undefined, floats, simple values

These eight major types are the fundamental CBOR data model defined in RFC 8949. :contentReference[oaicite:2]{index=2}

Example: Decode A1 61 61 01

A1 61 61 01

The first byte is A1. Its upper three bits identify major type 5, a map, and its argument is 1, so one key/value pair follows.

61 → Major type 3 → UTF-8 text string → length 1 61 → ASCII / UTF-8 "a" 01 → unsigned integer 1 Decoded: {"a": 1}

CBOR Unsigned Integers

Major type 0 directly represents non-negative integers from zero through the CBOR unsigned 64-bit range.

00 → 0 01 → 1 0A → 10 17 → 23 18 18 → 24 19 01 F4 → 500

When the value no longer fits in the five additional-information bits, additional bytes follow the initial byte.

CBOR Negative Integers

Major type 1 does not store the negative number as ordinary two’s complement. Instead the decoded value is:

value = -1 - argument

Therefore:

20 argument = 0 value = -1 21 argument = 1 value = -2

RFC 8949 defines major type 1 over the range −2^64 through −1. :contentReference[oaicite:3]{index=3}

CBOR Byte Strings

Major type 2 represents arbitrary binary bytes rather than Unicode text.

43 01 02 03 43 → byte string length 3 Payload: 01 02 03 Readable representation: h'010203'

The decoder preserves byte strings as hexadecimal instead of attempting to convert arbitrary binary data into text.

CBOR Text Strings

Major type 3 contains UTF-8 text. For a definite-length text string, the CBOR argument gives the number of encoded UTF-8 bytes, not the number of JavaScript characters.

65 68 65 6C 6C 6F 65 → text string length 5 68 65 6C 6C 6F → "hello"

Invalid UTF-8 in a text-string item is rejected instead of silently replacing bad bytes with guessed characters.

CBOR Arrays

Major type 4 represents an ordered collection of CBOR items. The items do not need to share the same type.

83 01 02 03 83 → array length 3 Elements: 1 2 3 Decoded: [1, 2, 3]

The array argument specifies the number of enclosed data items for a definite-length array. :contentReference[oaicite:4]{index=4}

CBOR Maps

Major type 5 contains key/value pairs. Unlike JSON objects, CBOR map keys do not have to be strings.

{ 1: "one", "two": 2 }

A CBOR decoder therefore should not automatically force every map into a normal JavaScript or JSON object, because doing so can lose information about non-string key types.

CBOR Semantic Tags

Major type 6 attaches a semantic tag number to exactly one following CBOR data item. The tag gives additional meaning understood by applications that support that tag.

C1 01 C1 → tag 1 01 → unsigned integer 1 Readable: 1(1)

For example, standard CBOR tag 1 is associated with epoch-based date/time values, but a generic structural decoder should preserve the tag and enclosed value rather than changing the data without displaying what was encoded. RFC 8949 specifies tag 1 as a numerical count of seconds relative to the Unix epoch. :contentReference[oaicite:5]{index=5}

CBOR Booleans, Null and Undefined

Major type 7 includes simple values. Common single-byte values include:

Hex Meaning
F4false
F5true
F6null
F7undefined

CBOR Floating-Point Numbers

Major type 7 also supports IEEE 754 floating-point values. Additional information 25, 26 and 27 indicate 16-bit half precision, 32-bit single precision and 64-bit double precision respectively. :contentReference[oaicite:6]{index=6}

FA 3F C0 00 00 FA → IEEE 754 float32 follows 3F C0 00 00 → 1.5

The decoder supports all three CBOR floating-point widths.

CBOR Indefinite-Length Items

CBOR can encode byte strings, text strings, arrays and maps without stating their final size at the beginning. These items use additional-information value 31 and end with the break byte FF. :contentReference[oaicite:7]{index=7}

9F 01 02 03 FF 9F → indefinite-length array 01 02 03 FF → break Decoded: [1, 2, 3]

The CBOR Break Stop Code

The break byte is:

FF

It is not an independent CBOR data value. It terminates an indefinite-length byte string, text string, array or map. A standalone break where a normal data item is required is not well-formed CBOR. :contentReference[oaicite:8]{index=8}

Reserved CBOR Additional Information Values

Additional-information values 28, 29 and 30 are reserved. RFC 8949 states that an item using one of these values is not well-formed under the current CBOR specification. :contentReference[oaicite:9]{index=9}

This decoder rejects those heads rather than trying to assign them an invented meaning.

CBOR vs JSON

JSON

Text format with strings, numbers, objects, arrays, booleans and null.

CBOR

Binary format with additional native concepts such as byte strings, tags, undefined, simple values and non-string map keys.

CBOR can represent JSON-like data efficiently, but CBOR should not be treated as merely compressed JSON because its data model is broader.

CBOR Network Byte Order

When an argument requires additional bytes, CBOR stores those argument bytes in network byte order, meaning most-significant byte first. RFC 8949 specifies 1-, 2-, 4- and 8-byte arguments for additional-information values 24 through 27. :contentReference[oaicite:10]{index=10}

19 01 F4 19 → unsigned integer with 2-byte argument 01 F4 → 0x01F4 → 500

Why CBOR Uses BigInt for Large Integers

CBOR directly supports unsigned values through 2^64−1 and negative integers down to −2^64. Those ranges exceed JavaScript Number’s exact integer range.

The decoder therefore uses BigInt while parsing integer arguments so that large encoded values are not silently rounded.

Malformed CBOR Detection

Truncated Payload

The encoded item ends before all bytes required by its declared length are available.

Reserved AI Value

Additional-information values 28–30 are rejected.

Unexpected Break

FF appears outside a valid indefinite-length context.

Invalid UTF-8

A major-type-3 text string contains bytes that are not valid UTF-8.

Wrong String Chunk Type

An indefinite byte/text string contains chunks of an incompatible type.

Incomplete Map Pair

An indefinite map ends after a key but before its corresponding value.

CBOR Decoder FAQs

What does CBOR stand for?
CBOR stands for Concise Binary Object Representation.
How do I decode CBOR hex?
Read the initial byte, separate its three major-type bits from the five additional-information bits, obtain any required argument bytes, and then decode the remaining content according to that major type.
What are the eight CBOR major types?
They are unsigned integer, negative integer, byte string, text string, array, map, semantic tag, and simple/floating-point values.
What does CBOR A1 mean?
A1 starts a major-type-5 map containing one key/value pair.
What does CBOR 83 mean?
83 starts a definite-length array containing three CBOR data items.
What does CBOR F5 mean?
F5 represents the Boolean value true.
What does CBOR F6 mean?
F6 represents null.
What does CBOR F7 mean?
F7 is the CBOR undefined simple value.
What is a CBOR byte string?
Major type 2 carries arbitrary binary bytes. It is distinct from major type 3, which carries UTF-8 text.
Can CBOR maps use integer keys?
Yes. CBOR map keys are CBOR data items and are not limited to strings.
What is a CBOR tag?
A semantic tag is major type 6. It contains a numeric tag identifier followed by exactly one tagged data item.
What is an indefinite-length CBOR array?
It is an array whose initial byte uses additional information 31 rather than a fixed element count and whose contents end with the break byte FF.
What is the CBOR break byte?
FF is the stop code that terminates an indefinite-length item. It is not a normal standalone data value.
Does CBOR support floating-point numbers?
Yes. CBOR supports IEEE 754 half-, single- and double-precision floating-point values.
Does CBOR use little endian?
No for numeric argument bytes. Multi-byte CBOR arguments are encoded in network byte order, most-significant byte first.
Can CBOR contain nested arrays and maps?
Yes. CBOR data items can be recursively nested to represent complex data structures.
Can CBOR represent more than JSON?
Yes. CBOR natively includes concepts such as byte strings, semantic tags, undefined, simple values and non-string map keys.
Can this tool decode 64-bit CBOR integers exactly?
Yes. Integer parsing uses JavaScript BigInt to avoid rounding values outside the exact Number range.

Decode CBOR Hexadecimal Data

Paste CBOR hexadecimal bytes to inspect major types, nested structures, integers, binary strings, UTF-8 text, arrays, maps, semantic tags, floating values and indefinite-length encoding in a readable structure.

Scroll to Top