--- id: dataclass-wizard version: "1.0.0" 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) license_treatment: permissive maintenance: active --- # dataclass-wizard — A wizard-like JSON serialization library for Python dataclasses License: permissive · Maintenance: active · Downloads: 4.9M/mo ## 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 above — 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 pip install dataclass-wizard uv add dataclass-wizard 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_current - Install friction: low - Maintenance: active - Downloads: 4.9M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags dataclass json serialization, python dataclass deserialization, json to dataclass conversion, type-safe dataclass loading, dataclass yaml toml support, automatic type coercion dataclass, environment variable dataclass mapping, serialization, dataclass, type-coercion [View on SkillFed](https://skillfed.io/packages/dataclass-wizard) · [View on PyPI](https://pypi.org/project/dataclass-wizard/)