skillfed

betterproto

A better Protobuf / gRPC generator & library

betterproto v1.2.5 3.6M downloads/30d#2,573 on PyPI1,769
Permissive license MIT AGING released

What it is and what it does

Betterproto is a code generator and runtime library that converts Protobuf 3 and gRPC service definitions into readable, idiomatic Python code. It addresses limitations in the official Google Protobuf Python plugin by generating dataclasses with type hints, async/await support, and modern Python conventions instead of the verbose, non-idiomatic code the official plugin produces. The generated messages support both binary and JSON serialization, timezone-aware datetime objects, and work with mypy for static type checking.

You install the package in two modes: with the `[compiler]` extra to get the protoc plugin for code generation, or without it to only use the runtime library for deserializing messages. Once generated, your Protobuf messages become standard Python dataclasses that feel native to the language, with methods like `to_json()`, `to_dict()`, and `parse()` rather than the camelCase method names of the official library.

Use it for:

  • Generate gRPC service stubs with async/await support for building high-concurrency microservices
  • Convert Protobuf definitions to typed Python dataclasses for IDE autocomplete and mypy validation
  • Serialize and deserialize messages to/from JSON with configurable field naming (camelCase or snake_case)
  • Build APIs where Protobuf messages integrate naturally with modern Python async frameworks
  • Replace the official Google Protobuf plugin when its generated code is unreadable or import paths break

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 support, JSON serialization, and modern type hints.

Yes, if you are committed to Protobuf 3 and value idiomatic, readable generated code with async support—but with caution. The package has not shipped a release since 2020-05-27 despite recent repository commits, signaling stalled maintenance at the release level. It remains suitable for new projects or teams already using it, but consider the risk of unpatched issues and incompatibility with future Protobuf or gRPC versions. No known security vulnerabilities.

Install

betterproto on PyPI

pip

pip install betterproto

uv

uv add betterproto

poetry

poetry add betterproto

Installing betterproto

Before you install

High install friction due to compiler dependencies. The package has not seen a release since 2020-05-27 despite repository activity through 2025-07-17, indicating maintenance has stalled at the release level. Suitable for projects already committed to Protobuf 3 and willing to manage aging tooling.

License in practice

MIT license permits commercial and private use with minimal restrictions, making it safe for most projects from a licensing standpoint.

Quickstart

# Install with compiler support
pip install "betterproto[compiler]"

# Generate from proto file
protoc -I . --python_betterproto_out=. example.proto

# Use generated code
import betterproto

@dataclass
class Message(betterproto.Message):
    value: str = betterproto.string_field(1)

test = Message(value="example")
serialized = bytes(test)
another = Message().parse(serialized)

Requires protoc (Protocol Buffer compiler) installed on the system; Python 3.6 or later.

Verify before relying

  • Current compatibility with Protobuf 3 versions released after 2020-05-27
  • Whether async gRPC support works with current grpclib versions
  • Active maintenance status given no releases in nearly 6 years despite recent commits

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.6)
Install friction high — source build required
Runtime dependencies none
Maintenance aging — 2,270 days since the last release
Last repo commit
First released
Downloads 3,575,811/month — #2,573 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: betterproto-1.2.5.tar.gz

Tags

protobuf code generation pythongrpc async pythonprotobuf to python dataclassmodern protobuf pythongrpc stub generationprotobuf json serializationpython protobuf compiler
protobuf-codegengrpc-asyncdataclass-generation

More Build Tools packages