Skip to main content

Protobuf Scalar Field Types

Protocol Buffers defines 15 scalar types. Each maps to a specific wire type and native language type. Choosing the right type affects wire size, language mapping, and serialization correctness.

All Scalar Types

TypeWire TypeDefaultC++JavaGo
double1 64-bit0.0doubledoublefloat64
float5 32-bit0.0floatfloatfloat32
int320 Varint0int32_tintint32
int640 Varint0int64_tlongint64
uint320 Varint0uint32_tint (unsigned semantics)uint32
uint640 Varint0uint64_tlong (unsigned semantics)uint64
sint320 Varint0int32_tintint32
sint640 Varint0int64_tlongint64
bool0 Varintfalseboolbooleanbool
string2 Len-delim""std::stringStringstring
bytes2 Len-delim""std::stringByteString[]byte
fixed325 32-bit0uint32_tint (unsigned semantics)uint32
fixed641 64-bit0uint64_tlong (unsigned semantics)uint64
sfixed325 32-bit0int32_tintint32
sfixed641 64-bit0int64_tlongint64

Wire Type Legend

Tag encoding: tag = (field_number << 3) | wire_type. Field 1, double = 0x09. Source: protobuf.dev encoding guide