--- id: dataclasses-avroschema version: "0.70.5" license: MIT license_treatment: permissive maintenance: active --- # dataclasses-avroschema — Generate Avro Schemas from Python classes. Serialize/Deserialize python instances with avro schemas License: permissive · Maintenance: active · Downloads: 1.3M/mo ## What it is and what it does Dataclasses Avro Schema bridges Python type definitions and Apache Avro serialization. It lets you define data structures as standard Python dataclasses or Pydantic models and automatically generates corresponding Avro schemas—the binary format specification that Avro uses for efficient, language-agnostic serialization. The package then handles bidirectional conversion: serialize Python instances to compact Avro binary or human-readable Avro-JSON, and deserialize those formats back into typed Python objects or dictionaries. The package is built on top of fastavro for the actual binary encoding/decoding, and integrates with dacite and inflection to handle type mapping and naming conventions. It supports complex nested structures, enums, optional fields, defaults, and metadata like namespaces and aliases. Optional extras let you extend it to work with Pydantic models or Faust streaming records, or add code generation and test data capabilities. Use it for: - Serialize Python dataclass instances to Avro binary for storage in Kafka topics or data lakes. - Generate Avro schemas from Pydantic models to document and validate API request/response contracts. - Deserialize Avro messages from a streaming platform back into typed Python objects for type-safe processing. - Convert between Python dataclasses and Avro-JSON for human-readable debugging or REST API payloads. - Define a single Python dataclass and automatically generate schema documentation for cross-team data contracts. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Generates Avro schemas from Python dataclasses, Pydantic models, and Faust Records, and serializes/deserializes Python instances to and from Avro binary or JSON formats. Yes. The package is actively maintained, has low install friction, carries no known vulnerabilities, and solves a real problem for teams using Avro serialization with Python. The MIT license is permissive. Install it if you need to work with Avro schemas in Python—either to generate them from your type definitions or to serialize/deserialize Avro data. ## Install pip install dataclasses-avroschema uv add dataclasses-avroschema poetry add dataclasses-avroschema ## Installing dataclasses-avroschema Before you install: Low friction install with a pure-Python wheel. Actively maintained with a recent release 9 days ago. Requires Python 3.10 or later. License in practice: MIT license permits commercial and private use with minimal restrictions—suitable for most projects. Quickstart: from dataclasses import dataclass from dataclasses_avroschema import AvroModel @dataclass class User(AvroModel): name: str age: int print(User.avro_schema()) user = User(name="john", age=20) print(user.serialize()) Requires Python 3.10 or later. Verify before relying: - Performance characteristics when serializing large nested structures or high-volume message streams. - Compatibility guarantees with specific Avro specification versions beyond 1.8.2. - Whether the pydantic, faust, faker, and cli extras are production-ready or still experimental. ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 1.3M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags avro schema generation from dataclasses, serialize deserialize avro python, pydantic avro schema, avro binary serialization, dataclass to avro, avro-json conversion, faust record avro, avro-serialization, schema-generation, data-interchange [View on SkillFed](https://skillfed.io/packages/dataclasses-avroschema) · [View on PyPI](https://pypi.org/project/dataclasses-avroschema/)