skillfed

betterproto2

A better Protobuf / gRPC generator & library

betterproto2 v0.10.0 916.8K downloads/30d#4,728 on PyPI170
Permissive license MIT Active released

What it is and what it does

Betterproto2 is a code generator and runtime library that converts Protobuf and gRPC definitions into readable, idiomatic Python code. Unlike the official Google protoc plugin, it generates modern Python using dataclasses, type hints, async/await syntax, and timezone-aware datetime objects, making the output both more Pythonic and easier to work with in contemporary codebases.

The library targets Protobuf 3 and modern Python (3.10+), and can generate Pydantic models alongside standard dataclasses. It handles both binary and JSON serialization natively. The project is a ground-up redesign of the original betterproto, still in active development with known breaking changes possible; it trades stability for the ability to fix bugs and add features the official plugin lacks.

Use it for:

  • Building async gRPC services in Python where the official protoc plugin's lack of native async support is a blocker.
  • Generating type-checkable Protobuf message classes that work seamlessly with mypy and IDE code completion.
  • Creating Pydantic-compatible models from Protobuf definitions for validation and serialization in modern frameworks.
  • Modernizing Protobuf workflows to use Python idioms (e.g., None instead of special wrapped types, datetime instead of Timestamp).
  • Replacing Google's protoc plugin when import path issues or name-clash bugs affect your project.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Generates idiomatic Python code from Protobuf and gRPC definitions, with built-in async/await support, type hints, and modern dataclass-based serialization.

Yes, if you are starting a new async gRPC project in Python 3.10+ and want modern, readable generated code with type support. Conditional caution: the project explicitly warns of active development and potential breaking changes, so pin versions carefully and review release notes before upgrading. Not suitable if you require long-term API stability or need to support Python versions below 3.10.

Install

betterproto2 on PyPI

pip

pip install betterproto2

uv

uv add betterproto2

poetry

poetry add betterproto2

Installing betterproto2

Before you install

Low install friction with only two lightweight runtime dependencies (python-dateutil and typing-extensions). Active maintenance with recent commits; however, the project is in active development and explicitly warns of potential breaking changes.

License in practice

MIT license permits commercial and private use with minimal restrictions; attribution required.

Quickstart

pip install betterproto2

import betterproto2

# Generated code uses modern Python dataclasses and async/await

Requires Python 3.10 or higher; Protobuf 3 and a protoc compiler setup.

Verify before relying

  • Whether generated code is fully compatible with existing protoc-generated code in mixed projects
  • Current state of Pydantic model generation support and completeness
  • Scope and timeline of documented breaking changes still expected during active development

Package facts

License MIT (permissive)
Python support supports the current Python release (<4.0,>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies 2 — python-dateutil, typing-extensions
Maintenance actively maintained — 96 days since the last release
Last repo commit
First released
Downloads 916,789/month — #4,728 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: betterproto2-0.10.0-py3-none-any.whl

Keywords: protobuf, gRPC

Tags

protobuf code generation pythongrpc python generatorasync protobuf pythonprotobuf to python dataclassmodern protobuf pythongrpc async pythonprotobuf type hints
protobuf-codegengrpc-asynctype-hints

More Build Tools packages

packaging

Provides reusable utilities for Python…

permissive · top 100 on PyPI

tqdm

Wraps any iterable to display a real-time…

copyleft · top 100 on PyPI

pip

pip is the standard installer for Python…

permissive · top 100 on PyPI

hatchling

Hatchling is a standards-compliant Python build…

permissive · top 100 on PyPI

grpcio-tools

Generates Python gRPC service stubs and message…

permissive · top 1,000 on PyPI

pre-commit

pre-commit is a framework for installing and…

permissive · top 1,000 on PyPI

betterproto2-compiler

Generates idiomatic Python code from Protobuf 3…

permissive · top 15,000 on PyPI

betterproto-rust-codec

Provides fast Rust-based conversion between…

permissive · top 15,000 on PyPI

betterproto

Generates idiomatic Python code from Protobuf 3…

permissive · top 5,000 on PyPI

betterproto-fw

Generates idiomatic Python code from Protobuf 3…

permissive · top 15,000 on PyPI

aristaproto

Generates Python gRPC stubs and message classes…

permissive · top 15,000 on PyPI

protobuf-py

Generates well-typed, readable Python code from…

permissive · top 15,000 on PyPI

envoy_data_plane

Provides Python dataclasses for the Envoy…

permissive · top 5,000 on PyPI

grpc-gateway-protoc-gen-openapiv2

Generates Python support code for gRPC Gateway…

permissive · top 15,000 on PyPI

protoc-gen-openapiv2

Generates Python support code for gRPC Gateway…

permissive · top 5,000 on PyPI

protobuf-py-ext

Native Rust-based encoder/decoder extension…

unclear · top 15,000 on PyPI