What protocol buffers are
Protocol buffers, often called protobuf, are a binary serialization format defined by a schema. You write a message definition, and a compiler generates code to encode and decode it in many languages.
Why binary and schema based
Compared to text formats like JSON, protobuf is smaller and faster to parse because fields are encoded by number, not by name.
- Each field has a unique field number used on the wire.
- Types and structure come from the shared schema.
- The compiler produces typed classes for each language.
Schema evolution
The field number is the key to backward compatibility. You can add new fields with new numbers, and old readers simply ignore what they do not recognize. Removing a field means reserving its number so it is never reused. Most fields are optional on the wire, so a missing field decodes to a default rather than failing. These rules let independently deployed services upgrade their messages without breaking each other, which is why protobuf pairs naturally with gRPC.
Key idea
Protocol buffers encode data compactly by field number against a shared schema, enabling safe evolution across services.