skillfed

dataclass-wizard

A wizard-like JSON serialization library for Python dataclasses

dataclass-wizard v1.0.0 4.9M downloads/30d#2,205 on PyPI247
Permissive 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) Active released

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-wizard

uv

uv add dataclass-wizard

poetry

poetry add dataclass-wizard

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseNatural Language :: EnglishProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.9Typing :: Typed

Tags

dataclass json serializationpython dataclass deserializationjson to dataclass conversiontype-safe dataclass loadingdataclass yaml toml supportautomatic type coercion dataclassenvironment variable dataclass mapping
serializationdataclasstype-coercion

More Software Development packages