dataclasses-json-speakeasy
Easily serialize dataclasses to and from JSON.
What it is and what it does
This library adds JSON serialization and deserialization methods to Python dataclasses through a simple decorator or mixin. It handles the boilerplate of converting dataclass instances to JSON strings or dictionaries, and reconstructing dataclass instances from JSON or dict input. The library supports nested dataclasses, standard collection types, and special types like datetime, UUID, and Decimal.
You apply the @dataclass_json decorator above @dataclass (or inherit from DataClassJsonMixin), then call .to_json(), .to_dict(), .from_json(), or .from_dict() on your class or instances. It also provides schema-based validation through a .schema() method backed by marshmallow, and supports field-level and class-level configuration for naming conventions like camelCase-to-snake_case conversion.
Use it for:
- Serialize API request/response dataclasses to JSON for HTTP communication
- Deserialize JSON payloads into typed dataclass instances with optional validation
- Convert between Python snake_case field names and JSON camelCase conventions
- Handle nested dataclass structures with automatic recursive encoding/decoding
- Validate incoming JSON data against dataclass field types using schema validation
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Converts Python dataclasses to and from JSON with a decorator or mixin, supporting nested types, collections, datetime, UUID, and Decimal objects.
Yes. The package is actively maintained, has no known vulnerabilities, installs with low friction, and solves a common problem cleanly. The MIT license imposes no restrictions. Install it if you need straightforward JSON serialization for dataclasses; the two-dependency footprint and decorator-based API make it a lightweight choice.
Install
dataclasses-json-speakeasy on PyPI
pip
pip install dataclasses-json-speakeasyuv
uv add dataclasses-json-speakeasypoetry
poetry add dataclasses-json-speakeasyInstalling dataclasses-json-speakeasy
Before you install
Low friction: pure Python wheel with only two runtime dependencies (typing-inspect and marshmallow). Repository is active with recent commits and no archived status.
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-speakeasy
from dataclasses import dataclass
from dataclasses_json import dataclass_json
@dataclass_json
@dataclass
class Person:
name: str
person = Person(name='alice')
json_str = person.to_json() # '{"name": "alice"}'
recovered = Person.from_json(json_str) # Person(name='alice')
Verify before relying
- Whether datetime encoding/decoding behavior (naive to aware conversion via system timezone) matches your application's requirements
- Performance characteristics when handling large nested dataclass hierarchies or collections
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.7,<4.0) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — typing-inspect, marshmallow |
| Maintenance | actively maintained — 925 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 880,954/month — #4,820 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: dataclasses_json_speakeasy-0.5.11-py3-none-any.whl
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
dataclasses-jsonConverts Python dataclasses to and from JSON…
permissive · top 1,000 on PyPI
typed-json-dataclassAdds JSON serialization and type validation to…
permissive · top 15,000 on PyPI
dataclass-wizardDataclass Wizard converts Python dataclasses to…
permissive · top 5,000 on PyPI
pysubtypesProvides enhanced subclasses for Python…
permissive · top 15,000 on PyPI
databind.jsonDeserializes and serializes Python dataclasses…
permissive · top 15,000 on PyPI
databindDatabind deserializes JSON-like nested data…
permissive · top 15,000 on PyPI
databind.coreDeserializes and serializes Python dataclasses…
permissive · top 15,000 on PyPI
json-encoderProvides JSON serialization with…
unclear · top 15,000 on PyPI
python-toonEncodes and decodes TOON (Token-Oriented Object…
permissive · top 15,000 on PyPI
edk2-pytool-libraryProvides Python classes and utilities for UEFI…
unclear · top 15,000 on PyPI