Protocol Buffers

Protocol Buffers

Language-neutral structured data serialization

Description

Passing data between two services, JSON is the path of least resistance — right up until the backend quietly renames userId to user_id and the frontend parses a screen full of undefined. Nothing stops that, because JSON carries no contract. And the same record repeats every field name on every row, which costs bandwidth and parse time once the volume is real. Protocol Buffers reverses the order: define the data structure in a .proto file first, then let the protoc compiler generate reader and writer code for each language. Fields travel as numbers rather than names, so payloads are far smaller than XML and parse faster.

It is the format Google has used internally for well over a decade, and being language-neutral is the point: one .proto definition generates C++, C#, Dart, Go, Java, Kotlin, Objective-C, Python, Ruby and Rust code, with PHP available under proto3. gRPC describes its services in the same language. Numbered fields make compatibility manageable — adding a field does not break old clients, and removing one only requires reserving its number so it is never reused.

The Windows release is a single protoc.exe: unzip and run, no installer.

Features



The .proto file is the contract: the structure lives in one file shared by every service and client, so a renamed field or a changed type is visible in the diff rather than discovered in production.

protoc code generation: one command emits reader and writer code for the target language — --python_out for Python, --java_out for Java — so nobody hand-writes serialization logic or gets it subtly wrong.

A dozen languages: official support for C++, C#, Dart, Go, Java, Kotlin, Objective-C, Python, Ruby and Rust, plus PHP under proto3, so a polyglot stack does not need a parser per language.

Small and fast: binary encoding with numbered fields produces messages smaller than XML or JSON and cheaper to parse, which shows up clearly at volume.

Controlled evolution: field numbers are fixed once assigned, older code ignores new fields, and retired fields are marked reserved so their numbers are never reused — schema changes stop being all-or-nothing.

Descriptor output: --descriptor_set_out writes the compiled schema to a descriptor file for tools that need to parse messages dynamically at runtime.

The interface language for gRPC: gRPC describes services and methods in .proto, so defining an API and defining a message use the same syntax.

No installer: the Windows archive unpacks to bin/protoc.exe — drop it on PATH and it works, with nothing written to the registry.

Open source: released by Google under a BSD license, with the compiler and every language runtime on GitHub.