dataclasses-json
Easily serialize dataclasses to and from JSON.
Decision gist · record as of 2026-08-14
Yes. The package is actively maintained, has no known vulnerabilities, installs with low friction, and solves a genuine pain point in JSON serialization for typed Python code. The MIT license carries no restrictions. Install it if you work with dataclasses and JSON; the decorator is simple to apply and the API is straightforward.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Low friction: pure Python wheel with only two runtime dependencies (marshmallow and typing-inspect).
- Actively maintained with recent commits; last release 796 days ago suggests stable maturity rather than abandonment.
License · maintenance · safety
MIT (permissive) — MIT license is permissive; you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
last release 2024-06-09 (796 days) · last repo commit 2026-05-05 · 1,486 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 67,739,139 downloads/mo, #480 on PyPI
Alternatives
Verify before relying
pip install dataclasses-json
from dataclasses import dataclass
from dataclasses_json import dataclass_json
@dataclass_json
@dataclass
class Person:
name: str
person = Person(name='lidatong')
person.to_json() # '{"name": "lidatong"}'
Person.from_json('{"name": "lidatong"}') # Person(name='lidatong')- Whether datetime encoding/decoding behavior (naive to aware conversion via system timezone) matches your application's requirements
- Performance characteristics when handling deeply nested dataclass structures or large collections
What it is and what it does
Dataclasses JSON is a decorator-based library that adds `.to_json()`, `.from_json()`, `.to_dict()`, and `.from_dict()` methods to Python dataclasses. It handles the boilerplate of serializing dataclass instances to JSON strings or dictionaries and deserializing JSON back into typed dataclass objects, with support for nested dataclasses, collections, datetime, UUID, and Decimal types.
The library sits between your dataclass definitions and the standard json module, letting you work with strongly-typed Python objects while transparently converting to/from JSON. It supports field-level and class-level configuration for naming conventions (e.g., camelCase to snake_case mapping) and optional schema validation via marshmallow integration, which can catch type mismatches that plain dataclass construction would allow.
Use it for
- Deserialize JSON API responses into typed dataclass objects for type-safe downstream processing
- Serialize dataclass instances to JSON for HTTP responses or file storage without manual dict construction
- Convert between snake_case Python field names and camelCase JSON conventions in web APIs
- Validate incoming JSON against dataclass field types using schema validation before object creation
- Handle nested dataclass hierarchies with automatic recursive encoding and decoding
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
The package is actively maintained, has no known vulnerabilities, installs with low friction, and solves a genuine pain point in JSON serialization for typed Python code. The MIT license carries no restrictions. Install it if you work with dataclasses and JSON; the decorator is simple to apply and the API is straightforward.
Install
dataclasses-json on PyPI
Before you install
Low friction: pure Python wheel with only two runtime dependencies (marshmallow and typing-inspect). Actively maintained with recent commits; last release 796 days ago suggests stable maturity rather than abandonment.
License in practice
MIT license is permissive; you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
Quickstart
pip install dataclasses-json
from dataclasses import dataclass
from dataclasses_json import dataclass_json
@dataclass_json
@dataclass
class Person:
name: str
person = Person(name='lidatong')
person.to_json() # '{"name": "lidatong"}'
Person.from_json('{"name": "lidatong"}') # Person(name='lidatong')
Verify before relying
- Whether datetime encoding/decoding behavior (naive to aware conversion via system timezone) matches your application's requirements
- Performance characteristics when handling deeply nested dataclass structures or large collections
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release <4.0,>=3.7 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 2 packagesmarshmallowtyping-inspect |
| Maintenance | Actively maintained 796 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 67,739,139 / month, #480 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | License :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9 |
Evidence: dataclasses_json-0.6.7-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “convert dataclass to json”
- dataclasses-jsonConverts Python dataclasses to and from JSON with minimal…
- typed-json-dataclassAdds JSON serialization and type validation to Python dataclasses,…
- dataclass-factoryConverts dataclasses to and from dictionaries and other common types…
Give your agent the search over MCP, or paste the wish link into any chat.
Similar packages
Converts Python dataclasses to and from JSON with a decorator or mixin, supporting nested types, collections, datetime, UUID, and Decimal objects.
Install it if you need straightforward JSON serialization for dataclasses; the two-dependency footprint and decorator-based API make it a lightweight choice.
Adds JSON serialization and type validation to Python dataclasses, letting you convert between dataclass instances and JSON/dict representations with automatic type checking.
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.
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.
Serialize and deserialize Python dataclasses to and from JSON, YAML, TOML, MsgPack, Pickle, and dict formats using a decorator-based API.
Converts dictionaries into dataclass instances with support for nested structures, type checking, optional fields, unions, generics, and custom type hooks.
Datafiles is a file-based ORM that automatically synchronizes Python dataclasses to disk files (YAML, JSON, TOML, JSON5) and back, treating the filesystem as a bidirectional persistence layer with minimal boilerplate.
Install it if you need automatic file-based persistence for configuration, state, or fixtures; skip it if you require a traditional database or need Python versions…
See also databind.json · dataclass-csv · djangorestframework-dataclasses · databind