Skip to main content

Protocol Buffers

Google’s language-neutral, platform-neutral, extensible mechanism for serializing structured data. Smaller, faster, and simpler than XML or JSON.

10+
Languages
3–10x
Smaller than JSON
70k+
GitHub Stars
2008
Open Sourced by Google

Define once, use everywhere

Write a .proto schema file, then generate type-safe code in any supported language.

addressbook.proto
syntax = "proto3";
package tutorial;

import "google/protobuf/timestamp.proto";

message Person {
  string name  = 1;
  int32  id    = 2;
  string email = 3;

  enum PhoneType {
    MOBILE = 0;
    HOME   = 1;
    WORK   = 2;
  }

  message PhoneNumber {
    string    number = 1;
    PhoneType type   = 2;
  }

  repeated PhoneNumber phones       = 4;
  google.protobuf.Timestamp last_updated = 5;
}

message AddressBook {
  repeated Person people = 1;
}

Why Protocol Buffers?

Language Neutral

Write your schema once in .proto format and generate idiomatic code for C++, Java, Python, Go, C#, Ruby, PHP, Rust, Objective-C, and more.

Compact and Fast

Binary encoding is 3–10x smaller than XML and JSON, with significantly faster serialization and deserialization throughput.

Schema Evolution

Add new fields without breaking existing code. Old clients ignore unknown fields; new clients handle missing old fields gracefully.

Strong Typing

Every message field has an explicit type. Generated code gives you compile-time type safety in statically-typed languages.

gRPC Integration

First-class support for defining RPC service interfaces. Used by Google and thousands of companies for inter-service communication.

Extensible

Write your own protoc plugins to generate custom code. Custom options let you annotate schemas with application-specific metadata.

Supported languages

Official runtimes are available for all major programming languages.

C++

The reference implementation. Includes the protoc compiler and a high-performance runtime with arena allocation.

Java

Full runtime for JVM including lite variant for Android and Kotlin extensions.

Python

Pure Python and C-extension implementations. Available on PyPI as protobuf.

C#

.NET runtime published to NuGet as Google.Protobuf. Supports .NET Standard 2.0+.

Go

Published at google.golang.org/protobuf. Full reflection and gRPC support.

Ruby

Available as the google-protobuf gem. Pure Ruby and native extension variants.

PHP

Available via Composer. Supports both pure PHP and C extension implementations.

Rust

Published as protobuf crate. High-performance with zero-copy parsing support.

Objective-C

Full runtime for iOS and macOS. Available via CocoaPods as Protobuf.

Start in minutes

Install the compiler, define your schema, and generate code for your language.

Quickstart

Define your first .proto file and generate code in your language of choice.

Installation

Install protoc and your language runtime from pre-built binaries or package managers.

Proto3 guide

Learn the proto3 language syntax: messages, fields, enums, services, and imports.

Encoding

Understand the binary wire format and how protobuf achieves its compact encoding.

Tooling

A rich ecosystem of tools to compile, validate, and integrate your proto schemas.

protoc

The Protocol Buffer compiler. Transforms .proto files into language-specific source code.

protoc plugins

Extend protoc with custom code generators for any language or framework.

Bazel

First-class Bazel rules: proto_library, cc_proto_library, java_proto_library, and more.

CMake

CMake integration for building the C++ runtime and using protobuf in CMake projects.

Build docs developers (and LLMs) love