dataclass-factory
An utility class for creating instances of dataclasses
What it is and what it does
dataclass_factory is a utility for bidirectional conversion between dataclass instances and dictionaries or other common types. It handles the boilerplate of parsing nested structures, enums, unions, and optional fields without requiring schema definitions. The factory pattern lets you load a dict into a typed dataclass instance with a single call, and dump instances back to dicts just as easily.
It's designed for scenarios where you need to deserialize external data (from APIs, configuration files, or databases) into strongly-typed Python objects, or serialize those objects back to plain data structures. The package supports cyclic references, generic dataclasses, and custom validators, making it suitable for complex domain models and data pipelines.
Use it for:
- Parse API responses into dataclass instances with automatic type validation and nested object handling.
- Load configuration files (JSON, YAML) into typed dataclass structures for application settings.
- Serialize dataclass instances back to dictionaries for database storage or API responses.
- Validate and transform user input by loading it into a dataclass with custom validators.
- Handle linked-list or tree structures where objects reference other instances of the same type.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Converts dataclasses to and from dictionaries and other common types with minimal configuration, supporting nested structures, enums, unions, and custom validation.
Yes. Low install friction, active maintenance, no security issues, and permissive licensing make it a safe choice. Use it when you need to convert between dataclasses and dictionaries without schema boilerplate—particularly for API clients, config loaders, or data pipelines where type safety matters.
Install
dataclass-factory on PyPI
pip
pip install dataclass-factoryuv
uv add dataclass-factorypoetry
poetry add dataclass-factoryInstalling dataclass-factory
Before you install
Low friction: pure Python wheel with only the standard library dataclasses module as a runtime dependency. Actively maintained with recent commits and no known vulnerabilities.
License in practice
Apache 2.0 permissive license allows commercial and private use with minimal restrictions; you may use, modify, and distribute the package freely provided you include a copy of the license.
Quickstart
pip install dataclass_factory
from dataclasses import dataclass
import dataclass_factory
@dataclass
class Book:
title: str
price: int
factory = dataclass_factory.Factory()
book = factory.load({"title": "Example", "price": 100}, Book)
data = factory.dump(book)
Verify before relying
- Whether the claimed 10x speed advantage over marshmallow and dataclasses.asdict holds in your specific use case.
- Whether automatic name style conversion (snake_case to CamelCase) is enabled by default or requires explicit configuration.
Package facts
| License | Apache2 (permissive) |
| Python support | supports the current Python release (>=3.6) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — dataclasses |
| Maintenance | actively maintained — 1,486 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 90,552/month — #13,579 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: dataclass_factory-2.16-py3-none-any.whl
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
adaptixAdaptix converts between data models,…
permissive · top 15,000 on PyPI
databind.jsonDeserializes and serializes Python dataclasses…
permissive · top 15,000 on PyPI
jsonsConverts Python objects (dataclasses, attrs…
permissive · top 5,000 on PyPI
itemadapterItemAdapter wraps data container objects…
permissive · top 5,000 on PyPI
class-resolverDynamically lookup and instantiate classes by…
permissive · top 15,000 on PyPI
databindDatabind deserializes JSON-like nested data…
permissive · top 15,000 on PyPI
typedloadLoads and dumps JSON-like data into typed…
copyleft · top 1,000 on PyPI
dataclass-wizardDataclass Wizard converts Python dataclasses to…
permissive · top 5,000 on PyPI
databind.coreDeserializes and serializes Python dataclasses…
permissive · top 15,000 on PyPI
flexparserflexparser lets you build parsers by writing…
permissive · top 5,000 on PyPI