skillfed

typed-json-dataclass

Make your dataclasses automatically validate their types

typed-json-dataclass v1.2.1 96.0K downloads/30d#13,242 on PyPI
Permissive license MIT Abandoned released

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

uv

uv add typed-json-dataclass

poetry

poetry add typed-json-dataclass

Installing 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

Development Status :: 5 - Production/StableEnvironment :: Web EnvironmentIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.7Topic :: Software Development :: Libraries :: Python Modules

Tags

dataclass json serializationtype validation dataclassesjson to dataclass conversiondto pattern pythondataclass type checkingjson schema validationserialize dataclass to json
dto-patternjson-serializationtype-validation

More Python Modules packages