CBOR Header Bytes

This table shows all possible CBOR header byte values and their meanings.

_0_1_2_3_4_5_6_7_8_9_a_b_c_d_e_f
0_0123456789101112131415
1_1617181920212223int 1+1int 1+2int 1+4int 1+8
2_-1-2-3-4-5-6-7-8-9-10-11-12-13-14-15-16
3_-17-18-19-20-21-22-23-24neg 1+1neg 1+2neg 1+4neg 1+8
4_bstr 0bstr 1bstr 2bstr 3bstr 4bstr 5bstr 6bstr 7bstr 8bstr 9bstr 10bstr 11bstr 12bstr 13bstr 14bstr 15
5_bstr 16bstr 17bstr 18bstr 19bstr 20bstr 21bstr 22bstr 23bstr 1+1bstr 1+2bstr 1+4bstr 1+8bstr indef
6_str 0str 1str 2str 3str 4str 5str 6str 7str 8str 9str 10str 11str 12str 13str 14str 15
7_str 16str 17str 18str 19str 20str 21str 22str 23str 1+1str 1+2str 1+4str 1+8str indef
8_arr 0arr 1arr 2arr 3arr 4arr 5arr 6arr 7arr 8arr 9arr 10arr 11arr 12arr 13arr 14arr 15
9_arr 16arr 17arr 18arr 19arr 20arr 21arr 22arr 23arr 1+1arr 1+2arr 1+4arr 1+8arr indef
a_map 0map 1map 2map 3map 4map 5map 6map 7map 8map 9map 10map 11map 12map 13map 14map 15
b_map 16map 17map 18map 19map 20map 21map 22map 23map 1+1map 1+2map 1+4map 1+8map indef
c_tag 0tag 1tag 2tag 3tag 4tag 5tag 6tag 7tag 8tag 9tag 10tag 11tag 12tag 13tag 14tag 15
d_tag 16tag 17tag 18tag 19tag 20tag 21tag 22tag 23tag 1+1tag 1+2tag 1+4tag 1+8
e_val 0val 1val 2val 3val 4val 5val 6val 7val 8val 9val 10val 11val 12val 13val 14val 15
f_val 16val 17val 18val 19falsetruenullundefval 1+1float 16float 32float 64break

Legend:

  • 1+1 = 1 header byte + 1 data byte (24...255)
  • 1+2 = 1 header byte + 2 data bytes (256...65535)
  • 1+4 = 1 header byte + 4 data bytes
  • 1+8 = 1 header byte + 8 data bytes
  • int = non-negative integer
  • neg = negative integer
  • bstr = byte string + length
  • str = UTF-8 text string + length
  • arr = array + length
  • map = map + length
  • tag = semantic tag + value
  • val = simple value
  • false = simple value 20
  • true = simple value 21
  • null = simple value 22
  • undef = simple value 23
  • float 16/32/64 = half/single/double precision float
  • indef = indefinite length
  • break = stop code for indefinite items