protoc— the Protocol Buffers compiler, which reads.protofiles and generates source code.- A language runtime — the library your application links against at runtime to serialize and parse messages.
Install protoc
For most users the simplest approach is to download a pre-built binary.Download a pre-built binary
Go to the protobuf releases page and download the zip package for your platform. The file is named Verify the installation:
protoc-$VERSION-$PLATFORM.zip and contains the protoc binary plus the standard .proto files distributed with protobuf.- Linux
- macOS
- Windows
If you need to use the latest unreleased version from the main branch, or you are working in C++ and need to build the library as part of your own project, see the Building from source section below.
Install the language runtime
After installingprotoc, install the runtime library for your language. Make sure the runtime version matches (or is newer than) your protoc version.
Python
Theprotobuf package on PyPI includes both a source distribution and binary wheels. The default backend is the upb C extension, which offers the best performance. A pure-Python fallback is available automatically if the C extension cannot be loaded.
Java
Addprotobuf-java as a dependency. Use the same version number as your protoc binary.
- Maven
- Gradle
JsonFormat and other utilities, also add:Kotlin
Kotlin protobuf builds on top of the Java runtime. You need both dependencies:.proto files:
C#
Install theGoogle.Protobuf NuGet package:
protoc.exe and the standard .proto files, install the tools package:
Ruby
Gemfile:
.proto files using:
PHP
Add the package via Composer:composer.json:
bcmath extension. A native C extension is also available via PECL for higher performance:
Building from source
Build from source if you need the latest unreleased version, want to modify the compiler, or are integrating protobuf as a C++ library in your own project.Bazel with Bzlmod
If you are using Bazel 8+ with Bzlmod, add the following to yourMODULE.bazel: