typed-json-dataclass
Make your dataclasses automatically validate their types
What it is and what it does
typed_json_dataclass extends Python's standard dataclass decorator with four new methods: from_dict(), from_json(), to_dict(), and to_json(). It lets you treat dataclasses as Data Transfer Objects (DTOs) by automatically converting between Python objects and JSON/dictionary representations while validating that incoming data matches your declared types. When you deserialize JSON or a dict into a dataclass, the library checks that each field's value matches its type annotation and raises a TypeError if it doesn't.
The library also supports mapping modes (e.g., converting between snake_case Python attributes and camelCase JSON keys) to bridge naming conventions. It handles nested dataclasses and collections recursively, making it useful for building typed API request/response handlers. However, the package has not been maintained since 2019-07-14, so it only officially supports Python 3.7 and may have compatibility issues with newer Python releases.
Use it for:
- Deserialize JSON API responses into typed dataclass instances with automatic validation of field types.
- Serialize dataclass instances to JSON for API requests, ensuring the output matches your schema.
- Implement the DTO pattern in REST API handlers by validating incoming request bodies against dataclass type definitions.
- Convert between snake_case Python code and camelCase JSON using MappingMode for cross-platform data exchange.
- Validate that configuration files (loaded as dicts) match expected structure before use in your application.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Adds JSON serialization and type validation to Python dataclasses, letting you convert between dataclass instances and JSON/dict representations with automatic type checking.
Yes, if you need lightweight DTO validation for a codebase on Python 3.7 and can accept the risk of an abandoned package. The library is stable for its intended use case and has no known vulnerabilities, but you should not adopt it for new projects without testing thoroughly on your target Python version. Consider actively maintained alternatives if long-term compatibility is a concern.
Install
typed-json-dataclass on PyPI
pip
pip install typed-json-dataclassuv
uv add typed-json-dataclasspoetry
poetry add typed-json-dataclassInstalling typed-json-dataclass
Before you install
Low install friction—pure Python wheel with a single runtime dependency. However, the package has been abandoned since its latest release on 2019-07-14, which means no bug fixes, security patches, or compatibility work for newer Python versions.
License in practice
MIT license is permissive, allowing commercial and private use with minimal restrictions—you may use, modify, and distribute the code freely as long as you include the license notice.
Quickstart
pip install typed-json-dataclass
from dataclasses import dataclass
from typed_json_dataclass import TypedJsonMixin
@dataclass
class Person(TypedJsonMixin):
name: str
age: int
bob = Person(name='Bob', age=24)
print(bob.to_json())
Requires Python >=3.7,<4.0; abandoned status means no support for Python versions released after 2019-07-14.
Verify before relying
- Whether the package works reliably with Python versions beyond those released in 2019.
- Current compatibility with modern versions of flake8-tuple (its only runtime dependency).
- Whether type validation catches all common type mismatches or has known gaps.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.7,<4.0) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — flake8-tuple |
| Maintenance | abandoned — 2,588 days since the last release |
| First released | |
| Downloads | 95,962/month — #13,242 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: typed_json_dataclass-1.2.1-py3-none-any.whl
Keywords: dataclasses, dataclass, json, mypy, pyre, marshmallow, attrs, cattrs
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
cattrsConverts unstructured dictionaries into…
permissive · top 1,000 on PyPI
daciteConverts dictionaries into dataclass instances…
permissive · top 1,000 on PyPI
dataclass-csvReads and writes CSV files using Python…
permissive · top 15,000 on PyPI
dataclasses-jsonConverts Python dataclasses to and from JSON…
permissive · top 1,000 on PyPI
dataclasses-json-speakeasyConverts Python dataclasses to and from JSON…
permissive · top 5,000 on PyPI
dataclasses-jsonschemaGenerates JSON Schema from Python dataclasses…
permissive · top 15,000 on PyPI
dataclass-wizardDataclass Wizard converts Python dataclasses to…
permissive · top 5,000 on PyPI
dataclassesProvides the PEP 557 dataclasses module for…
permissive · top 5,000 on PyPI
datafilesDatafiles is a file-based ORM that…
permissive · top 15,000 on PyPI
jsonsConverts Python objects (dataclasses, attrs…
permissive · top 5,000 on PyPI