The wire format is how a message is turned into bytes that one program can send and another can read. This chapter covers those bytes, which the rest of Protobuf is built on.
A serialized Protobuf message is a flat stream of tag/value pairs. Each tag names a field by number and says what its wire type is. The wire type tells the decoder how many bytes the value takes up. The payload has no header, no field count, and no schema. The decoder just reads fields one after another until the bytes run out.
Most of the format's compactness comes from the varint, which takes a number of bytes that depends on the number's actual size, not its declared width. Tags, lengths, and most integer values are all varints, and ZigZag extends the same encoding to negative numbers.
The Binary Explorer lets you check any of it against real bytes. Edit a schema and a message, and it shows you the annotated encoding, byte by byte.
If you run into an edge case we don't cover here, the official encoding guide has the full specification.
Next
Binary 101
Bits, bytes, endianness, and the bit shifting the rest of the wire format builds on.