dataclass-wizard
A wizard-like JSON serialization library for Python dataclasses
What it is and what it does
Dataclass Wizard is a serialization library that extends Python dataclasses with mixin classes to handle conversion to and from JSON, YAML, TOML, and environment variables. It uses code generation to create fast loaders and dumpers, automatically coercing types (e.g., converting string "123" to integer 123) and transforming key casing between formats. The library is pure Python with minimal dependencies and supports modern Python versions (3.9+).
You use it by subclassing from one of its mixin classes—JSONWizard for JSON, EnvWizard for environment variables, or the base DataclassWizard—which adds methods like from_dict(), to_dict(), from_json(), and to_json(). It handles nested dataclasses, collections, typing generics, and standard types like Enum and datetime. Custom type hooks allow you to extend support for unsupported types without modifying the library itself.
Use it for:
- Load configuration from JSON or YAML files into typed dataclass schemas with automatic validation and type conversion.
- Serialize API request/response dataclasses to JSON with custom key casing (e.g., snake_case to camelCase).
- Populate dataclass instances from environment variables or .env files with type coercion.
- Convert lists of dictionaries from external APIs into lists of typed dataclass instances.
- Build CLI tools that accept JSON input and output typed, validated dataclass objects.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Dataclass Wizard converts Python dataclasses to and from JSON, YAML, TOML, and environment variables with automatic type coercion and case transformation, using code-generated serialization for performance.
Yes. Dataclass Wizard is actively maintained, has no known vulnerabilities, low install friction, and permissive licensing. It fills a genuine gap for lightweight, type-safe dataclass serialization without the overhead of heavier validation frameworks. Install it if you need JSON/YAML/TOML/environment variable marshalling for dataclasses and want automatic type coercion and case transformation out of the box.
Install
dataclass-wizard on PyPI
pip
pip install dataclass-wizarduv
uv add dataclass-wizardpoetry
poetry add dataclass-wizardInstalling dataclass-wizard
Before you install
Low friction install with a single runtime dependency (typing-extensions). Actively maintained with a recent release (42 days ago) and no known vulnerabilities. Repository shows 247 stars and steady development.
License in practice
Licensed under Apache License 2.0 (permissive), allowing commercial and private use with minimal restrictions—suitable for most projects that can include a license notice.
Quickstart
pip install dataclass-wizard
from dataclasses import dataclass
from dataclass_wizard import JSONWizard
@dataclass
class Data(JSONWizard):
value: int
data = Data.from_dict({"value": "123"})
print(data.to_json())
Requires Python 3.9 or later; Python 3.6–3.8 users must install version 0.26.1.
Verify before relying
- Performance characteristics compared to other dataclass serialization libraries in production workloads.
- Completeness of YAML and TOML support relative to their respective standard libraries.
- Behavior and limitations when handling deeply nested or circular dataclass structures.
Package facts
| License | Apache Software License 2.0 Copyright (c) 2021, Ritvik Nag Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may… (full text in the JSON record) (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — typing-extensions |
| Maintenance | actively maintained — 42 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 4,903,540/month — #2,205 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: dataclass_wizard-1.0.0-py3-none-any.whl
Keywords: dataclasses, wizard, json, serialization, deserialization, dataclass serialization, type hints, performance, alias, python, env, dotenv, lightweight
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI 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
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
databind.jsonDeserializes and serializes Python dataclasses…
permissive · top 15,000 on PyPI
datafilesDatafiles is a file-based ORM that…
permissive · top 15,000 on PyPI
jax-dataclassesProvides a JAX-compatible wrapper around Python…
permissive · top 15,000 on PyPI
databindDatabind deserializes JSON-like nested data…
permissive · top 15,000 on PyPI
daciteConverts dictionaries into dataclass instances…
permissive · top 1,000 on PyPI
linkml-runtimeProvides runtime support for LinkML-generated…
permissive · top 15,000 on PyPI
dataclass-factoryConverts dataclasses to and from dictionaries…
permissive · top 15,000 on PyPI
typed-json-dataclassAdds JSON serialization and type validation to…
permissive · top 15,000 on PyPI
dataclasses-jsonConverts Python dataclasses to and from JSON…
permissive · top 1,000 on PyPI
pyserdeSerialize and deserialize Python dataclasses to…
permissive · top 5,000 on PyPI