skillfed

dataclasses-json-speakeasy

Easily serialize dataclasses to and from JSON.

dataclasses-json-speakeasy v0.5.11 881.0K downloads/30d#4,820 on PyPI1,486
Permissive license MIT Active released

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

uv

uv add dataclasses-json-speakeasy

poetry

poetry add dataclasses-json-speakeasy

Installing 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

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

Tags

dataclass json serializationserialize dataclasses to jsonjson encoding decoding dataclassespython dataclass json converterdataclass schema validationcamelcase snake_case json conversionnested dataclass json
serializationjsondataclass

More Software Development packages