Explain the Protocol Buffers binary wire format — how are fields encoded as tag-length-value and what makes it compact compared to JSON?

Last updated 8 July 2026

  • Each field is a key plus value. The key is a varint (variable-length integer) holding (field_number << 3) | wire_type.

  • Wire type sets the layout: 0 = varint, 1/5 = fixed 64/32-bit, 2 = length-delimited (a length prefix before strings, bytes, or nested messages, giving tag-length-value).

  • It beats JSON by dropping field names and punctuation, encoding numbers as binary varints, and omitting fields at default values.

  • https://medium.com/@ankitrathod/demystifying-the-wire-how-i-accidentally-understood-json-vs-protobuf-97a5dc6738bd?sharedUserId=ankitrathod
  • https://kreya.app/blog/protocolbuffers-wire-format/
  • https://victoriametrics.com/blog/go-protobuf/
All gRPC interview questions