--- id: dataclasses-json version: "0.6.7" license: MIT license_treatment: permissive maintenance: active --- # dataclasses-json — Easily serialize dataclasses to and from JSON. License: permissive · Maintenance: active · Popularity: top 1,000 on PyPI ## Install pip install dataclasses-json uv add dataclasses-json poetry add dataclasses-json ## Description # Dataclasses JSON ![](https://github.com/lidatong/dataclasses-json/workflows/dataclasses-json/badge.svg) This library provides a simple API for encoding and decoding [dataclasses](https://docs.python.org/3/library/dataclasses.html) to and from JSON. It's very easy to get started. [README / Documentation website](https://lidatong.github.io/dataclasses-json). Features a navigation bar and search functionality, and should mirror this README exactly -- take a look! ## Quickstart `pip install dataclasses-json` ```python 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"}' <- this is a string person.to_dict() # {'name': 'lidatong'} <- this is a dict Person.from_json('{"name": "lidatong"}') # Person(1) Person.from_dict({'name': 'lidatong'}) # Person(1) # You can also apply _schema validation_ using an alternative API # This can be useful for "typed" Python code Person.from_json('{"name": 42}') # This is ok. 42 is not a `str`, but # dataclass creation does not validate... ## AI interpretation — verify before relying Serializes Python dataclasses to and from JSON with minimal boilerplate, supporting nested structures, custom field naming conventions, and schema validation via marshmallow. Verdict: Mature, actively maintained library with no known vulnerabilities and permissive licensing. Low install friction and broad Python version support (3.7–3.12) make it a reliable choice for dataclass-to-JSON serialization in production environments. [View on SkillFed](https://skillfed.io/packages/dataclasses-json) · [View on PyPI](https://pypi.org/project/dataclasses-json/)