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.
0x prefixes are accepted. Continuous hexadecimal input also works.
| # | Path | Offset | Major Type | Decoded Type | Value / Length | Encoded Bytes |
|---|
-
-
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 |
|---|---|---|
| 0 | Unsigned Integer | Argument is the value |
| 1 | Negative Integer | Value = −1 − argument |
| 2 | Byte String | Binary bytes |
| 3 | Text String | UTF-8 text |
| 4 | Array | Ordered CBOR items |
| 5 | Map | Key/value item pairs |
| 6 | Semantic Tag | Tag number + one enclosed item |
| 7 | Simple / Float | Booleans, 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 |
|---|---|
| F4 | false |
| F5 | true |
| F6 | null |
| F7 | undefined |
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?
How do I decode CBOR hex?
What are the eight CBOR major types?
What does CBOR A1 mean?
What does CBOR 83 mean?
What does CBOR F5 mean?
What does CBOR F6 mean?
What does CBOR F7 mean?
What is a CBOR byte string?
Can CBOR maps use integer keys?
What is a CBOR tag?
What is an indefinite-length CBOR array?
What is the CBOR break byte?
Does CBOR support floating-point numbers?
Does CBOR use little endian?
Can CBOR contain nested arrays and maps?
Can CBOR represent more than JSON?
Can this tool decode 64-bit CBOR integers exactly?
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.