Skip to content

When multiple fields are sent together, Protobuf just concatenates them into one binary stream. The decoder doesn't need separators between fields. Each field tells the decoder how many bytes to consume before it moves on.

  1. 01

    Read the tag

    The first varint in each field is the tag. Its lower three bits identify the wire type, and the remaining bits identify the field number.

  2. 02

    Read the payload

    The wire type tells the decoder where the payload ends. A varint ends at the first byte with its top bit clear, so the end is found while reading it. A fixed field is 4 or 8 bytes. A length-delimited field carries its size in a prefix.

  3. 03

    Consume that field

    The decoder takes exactly those bytes, maps them to the schema field when it recognizes the number, and moves to the next field.

  4. 04

    Repeat to the end

    The stream carries no outer field count. Parsing picks up at the next byte and continues until the end of the message.

Protobuf FieldsBinary Stream (Hex)string name = 1Value: "Alice"0aTag05Len41 6c 69 63 65Dataint32 id = 2Value: 15010Tag96 01Datafloat score = 3Value: 95.51dTag00 00 bf 42DataField TagLength PrefixValue Payload

Next

Binary Explorer

An interactive Protobuf binary explorer: edit a schema and message, then inspect the encoded bytes with every tag, length, and value annotated.