betterproto2-compiler
Compiler for betterproto2
What it is and what it does
betterproto2-compiler is a code generator that transforms Protobuf 3 and gRPC definitions into readable, idiomatic Python code. It reimplements Google's protoc plugin from the ground up, prioritizing modern Python idioms—dataclasses, async/await, type hints, and built-in datetime objects—over legacy patterns. The generated code includes both binary and JSON serialization, supports Pydantic model generation, and produces importable modules with proper `__init__.py` files.
The package addresses long-standing limitations of the official protoc plugin: it adds native async support, full type checking and IDE completion, relative imports that work in Python 3, and avoids name-collision bugs. While the wire format remains compatible with standard Protobuf, the generated API differs—using Pythonic method names and patterns instead of capitalized functions like `HasField()` or `SerializeToString()`. The project is actively developed but explicitly subject to breaking changes, and documentation is incomplete.
Use it for:
- Generate async gRPC service stubs and client code without requiring additional plugins or manual async wrapping.
- Create type-hinted, IDE-friendly Python dataclasses from Protobuf schemas for better developer experience and static analysis.
- Build Pydantic-compatible models directly from Protobuf definitions for validation and serialization workflows.
- Modernize Protobuf-based Python projects by replacing Google's protoc plugin with idiomatic, readable generated code.
- Develop microservices that use Protobuf for serialization while leveraging Python's async/await and modern language features.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Generates idiomatic Python code from Protobuf 3 and gRPC definitions, with built-in async/await support, type hints, and modern Python features like dataclasses and timezone-aware datetime objects.
Yes, with conditions. Install if you need async gRPC support, type hints, and idiomatic Python code generation from Protobuf 3 schemas. The low install friction, active maintenance, and MIT license support adoption. However, accept that the project is under active development with incomplete documentation and potential breaking changes—unsuitable for production systems requiring stability guarantees.
Install
betterproto2-compiler on PyPI
pip
pip install betterproto2-compileruv
uv add betterproto2-compilerpoetry
poetry add betterproto2-compilerInstalling betterproto2-compiler
Before you install
Low install friction with a pure-wheel distribution. The package is actively maintained with a recent commit history, though it explicitly notes ongoing development and potential breaking changes.
License in practice
MIT license permits free use, modification, and distribution with minimal restrictions, making it suitable for both open-source and commercial projects.
Quickstart
pip install betterproto2-compiler
from betterproto2 import Message
class Example(Message):
name: str = 1
Requires Python 3.10 or higher; the package is under active development and may introduce breaking changes.
Verify before relying
- Exact scope of breaking changes expected during active development and timeline for stabilization
- Whether generated code is fully compatible with standard gRPC tooling and ecosystems
- Performance characteristics compared to the original betterproto or Google's protoc plugin
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (<4.0,>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 5 — betterproto2, ruff, jinja2, typing-extensions, strenum |
| Maintenance | actively maintained — 93 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 119,230/month — #12,079 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: betterproto2_compiler-0.10.1-py3-none-any.whl
Keywords: protobuf, gRPC, compiler
Tags
More Build Tools packages
Provides reusable utilities for Python…
permissive · top 100 on PyPI
tqdmWraps any iterable to display a real-time…
copyleft · top 100 on PyPI
pippip is the standard installer for Python…
permissive · top 100 on PyPI
hatchlingHatchling is a standards-compliant Python build…
permissive · top 100 on PyPI
grpcio-toolsGenerates Python gRPC service stubs and message…
permissive · top 1,000 on PyPI
pre-commitpre-commit is a framework for installing and…
permissive · top 1,000 on PyPI
betterproto2Generates idiomatic Python code from Protobuf…
permissive · top 5,000 on PyPI
betterprotoGenerates idiomatic Python code from Protobuf 3…
permissive · top 5,000 on PyPI
betterproto-rust-codecProvides fast Rust-based conversion between…
permissive · top 15,000 on PyPI
betterproto-fwGenerates idiomatic Python code from Protobuf 3…
permissive · top 15,000 on PyPI
aristaprotoGenerates Python gRPC stubs and message classes…
permissive · top 15,000 on PyPI
protoc-gen-openapiv2Generates Python support code for gRPC Gateway…
permissive · top 5,000 on PyPI
protobuf-pyGenerates well-typed, readable Python code from…
permissive · top 15,000 on PyPI
grpc-gateway-protoc-gen-openapiv2Generates Python support code for gRPC Gateway…
permissive · top 15,000 on PyPI
envoy_data_planeProvides Python dataclasses for the Envoy…
permissive · top 5,000 on PyPI