Skip to main content

Nil and Boolean

MessagePack nil (null), false, and true each encode as a single byte. nil = 0xc0, false = 0xc2, true = 0xc3. No additional bytes follow. These are the simplest MessagePack formats.

Description

nil, false, and true are single-byte values in MessagePack. Each is represented by a unique byte with no additional data: 0xc0 = nil (null) 0xc2 = false 0xc3 = true

Note that 0xc1 is reserved (never-used byte). This single-byte encoding makes nil and boolean values cheaper than in JSON where 'null' is 4 bytes, 'true' is 4 bytes, and 'false' is 5 bytes.

Format Variants

NameFirst ByteRangeDescription
nil0xc0N/ANull/nil. Single byte, no data follows.
false0xc2N/ABoolean false. Single byte.
true0xc3N/ABoolean true. Single byte.

Examples

LabelHexValue
nilc0null
falsec2false
truec3true

See Also