pydantic-avro
Converting pydantic classes to avro schemas
What it is and what it does
pydantic-avro bridges pydantic data models and Apache Avro schemas. It lets you define a pydantic class that inherits from AvroBase, then export it as an Avro schema dictionary for serialization or integration with Avro-based systems. It also works in reverse: you can provide an Avro schema file and generate a pydantic class from it via a command-line tool. The library supports explicit Avro type specification through pydantic Field annotations, so you can control how Python types map to Avro types when the default inference isn't what you need.
The package is lightweight, depending only on pydantic itself. It's useful in data pipelines, message brokers, and systems that need both pydantic's validation and Avro's schema portability. The CLI tool makes it easy to generate boilerplate code from existing Avro schemas without manual translation.
Use it for:
- Generate Avro schemas from pydantic models for use in Kafka producers or other Avro-based message systems
- Convert existing Avro schema files into pydantic classes to maintain type safety in Python applications
- Explicitly map Python datetime fields to Avro timestamp types or other non-default Avro representations
- Automate schema generation in data pipelines where both validation and schema registry integration are needed
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Converts between pydantic class definitions and Apache Avro schemas in both directions, enabling serialization and schema generation for data validation workflows.
Yes. Low install friction, active maintenance, no known vulnerabilities, and a permissive MIT license make it a safe choice. Install it if you need bidirectional conversion between pydantic and Avro—either to export pydantic models for Avro systems or to generate pydantic classes from Avro schemas.
Install
pydantic-avro on PyPI
pip
pip install pydantic-avrouv
uv add pydantic-avropoetry
poetry add pydantic-avroInstalling pydantic-avro
Before you install
Low install friction with a single runtime dependency on pydantic. Actively maintained with recent commits; last release 189 days ago with an active repository.
License in practice
MIT license permits commercial and private use with minimal restrictions; suitable for most projects without licensing concerns.
Quickstart
pip install pydantic-avro
from pydantic_avro.base import AvroBase
class TestModel(AvroBase):
key1: str
key2: int
schema_dict = TestModel.avro_schema()
print(schema_dict)
Verify before relying
- Whether the package handles complex nested pydantic models and all Avro logical types beyond the examples shown
- Performance characteristics when converting large or deeply nested schemas
- Compatibility guarantees with different pydantic versions beyond the implicit dependency
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (<4.0,>=3.8.1) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — pydantic |
| Maintenance | actively maintained — 189 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,401,151/month — #3,080 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pydantic_avro-0.10.0-py3-none-any.whl
Keywords: pydantic, avro
Tags
More Application Frameworks packages
FastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
textualTextual is a Python framework for building…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
mcpBuild and connect to Model Context Protocol…
permissive · top 1,000 on PyPI
WerkzeugWerkzeug is a WSGI utility library providing…
permissive · top 1,000 on PyPI
py-avro-schemaGenerates Apache Avro schemas from Python…
permissive · top 15,000 on PyPI
pydantic-sparkConverts Pydantic class definitions to Apache…
permissive · top 15,000 on PyPI
dataclasses-avroschemaGenerates Avro schemas from Python dataclasses,…
permissive · top 5,000 on PyPI
avro-genGenerates typed Python record classes and a…
permissive · top 15,000 on PyPI
avro-gen3Generates typed Python record classes and a…
permissive · top 5,000 on PyPI
avro-python3Serializes and deserializes data in Apache Avro…
permissive · top 5,000 on PyPI
avro-validatorValidates Python data against Avro schemas and…
permissive · top 15,000 on PyPI
jsonschema-pydanticConverts JSON Schema definitions into Pydantic…
unclear · top 15,000 on PyPI
dydanticDynamically generates Pydantic models from JSON…
permissive · top 5,000 on PyPI
avroApache Avro is a data serialization system that…
permissive · top 5,000 on PyPI