$npx skillfedfor your agent

cattrs

Composable complex class support for attrs and dataclasses.

Worth itPyPI Released Feb 202673.8M downloads / moMITPure Python

Decision gist · record as of 2026-08-14

pure-Python wheel — cattrs-26.1.0-py3-none-any.whl
v26.1.0 · released 2026-02-18 · Python >=3.10 · 3 runtime deps: attrs, exceptiongroup, typing-extensions

Yes. cattrs is actively maintained, permissively licensed, has low install friction, and solves a common problem—bridging unstructured and typed data—without requiring you to pollute your models with serialization logic. It's a good fit if you work with attrs or dataclasses and need flexible, recursive (un)structuring with validation.AI-flagged interpretation of the facts on this page — verify before relying

Before you install

  • Requires Python 3.10 or later.
  • Low friction installation with three lightweight runtime dependencies (attrs, exceptiongroup, typing-extensions).
  • Actively maintained as of 2026-02-18 with recent commits and 1049 repository stars.

License · maintenance · safety

MIT (permissive) — MIT license permits unrestricted commercial and private use with minimal obligations—only attribution required.

last release 2026-02-18 (177 days) · last repo commit 2026-08-09 · 1,049 stars

0 known vulnerabilities (OSV.dev, 2026-08-14) · 73,830,482 downloads/mo, #455 on PyPI

Verify before relying

from attrs import define
from cattrs import structure, unstructure

@define
class C:
    a: int
    b: list[str]

instance = structure({'a': 1, 'b': ['x', 'y']}, C)
unstructure(instance)
  • Performance characteristics compared to alternative serialization libraries under real-world workloads.
  • Extent of support for complex union disambiguation beyond the documented unique-field strategy.
Same gist for agents: .md · .json

What it is and what it does

cattrs is a data (un)structuring library that bridges unstructured data (dictionaries, JSON) and typed Python objects. It converts dictionaries into attrs classes or dataclasses recursively, validating types along the way, and can reverse the process to serialize objects back to dictionaries. The library keeps serialization rules separate from your data models, so you can define multiple conversion strategies for the same class without modifying it.

It handles nested structures, optional fields, collections (lists, sets, tuples, dicts), TypedDict, and custom types through registered hooks. The package includes pre-configured converters for JSON, msgpack, CBOR, BSON, YAML, TOML, and other serialization formats. Runtime dependencies are minimal: attrs (which it's designed around), exceptiongroup (for grouped validation errors), and typing-extensions (for type hint compatibility).

Use it for

  • Deserialize API responses or configuration files into typed dataclasses with automatic validation.
  • Convert database query results into attrs classes while enforcing field types and constraints.
  • Build data pipelines that transform unstructured input into strongly-typed intermediate objects.
  • Serialize domain models to multiple formats (JSON, YAML, msgpack) without adding format-specific code to the model.
  • Validate and normalize user input from web forms or CLI arguments into typed objects.

Worth the install?

AI-flagged interpretation of the facts on this page. Verify before relying on it.

Worth it

Yes.

cattrs is actively maintained, permissively licensed, has low install friction, and solves a common problem—bridging unstructured and typed data—without requiring you to pollute your models with serialization logic. It's a good fit if you work with attrs or dataclasses and need flexible, recursive (un)structuring with validation.

Install

cattrs on PyPI

Before you install

Low friction installation with three lightweight runtime dependencies (attrs, exceptiongroup, typing-extensions). Actively maintained as of 2026-02-18 with recent commits and 1049 repository stars.

Requires Python 3.10 or later.

License in practice

MIT license permits unrestricted commercial and private use with minimal obligations—only attribution required.

Quickstart

from attrs import define
from cattrs import structure, unstructure

@define
class C:
    a: int
    b: list[str]

instance = structure({'a': 1, 'b': ['x', 'y']}, C)
unstructure(instance)

Verify before relying

  • Performance characteristics compared to alternative serialization libraries under real-world workloads.
  • Extent of support for complex union disambiguation beyond the documented unique-field strategy.

Package facts

LicenseMIT permissive
Python supportSupports the current Python release >=3.10
Install frictionLow. Pure-Python wheel
Runtime dependencies
3 packages
attrsexceptiongrouptyping-extensions
MaintenanceActively maintained 177 days since the last release
Last repo commit
First released
Downloads73,830,482 / month, #455 on PyPI 30-day window, as of 2026-08-14
Known vulnerabilitiesNone known OSV.dev, checked 2026-08-14
Classifiers
Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTyping :: Typed

Evidence: cattrs-26.1.0-py3-none-any.whl

Tags

Capabilities
dict to class conversionattrs dataclass serializationrecursive data validationunstructure structure datatyped data conversionclass instance validationnested object deserialization
Topics
serializationvalidationattrs-dataclasses
PyPI keywords
attrsdataclassesserialization

Let your AI agent find packages like this

Example. Real query, live index.

You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.

wish › “dict to class conversion”

  • cattrsConverts unstructured dictionaries into properly typed Python classes…
  • dict2xmlConverts Python dictionaries into XML strings with configurable…
  • desertDesert generates marshmallow serialization schemas automatically from…

Give your agent the search over MCP, or paste the wish link into any chat.

Similar packages

attrs Worth it
PyPI · released Mar 2026

attrs is a Python library that automatically generates common class methods (__init__, __repr__, __eq__, etc.) from declarative attribute definitions, eliminating boilerplate code while maintaining runtime performance.

Install it if you write classes regularly.

MITpure Python · 3.9+
924.9Mdownloads / mo
fields Skip
PyPI · Utilities · released Apr 2016

Generates lightweight container classes with automatic `__repr__`, comparison methods, and field initialization from a fluent attribute-chain syntax, eliminating boilerplate for simple data holders.

No, not for new projects.

BSD-3-Clausepure Pythonabandoned
78.8Kdownloads / mo
typed-json-dataclass With conditions
PyPI · Python Modules · released Jul 2019

Adds JSON serialization and type validation to Python dataclasses, letting you convert between dataclass instances and JSON/dict representations with automatic type checking.

MITpure Pythonabandoned
96.0Kdownloads / mo
dataclass-wizard Worth it
PyPI · Software Development · released Jul 2026

Dataclass Wizard converts Python dataclasses to and from JSON, YAML, TOML, and environment variables with automatic type coercion and case transformation, using code-generated serialization for performance.

Install it if you need JSON/YAML/TOML/environment variable marshalling for dataclasses and want automatic type coercion and case transformation out of the box.

Apache-2.0pure Python · 3.9+
4.9Mdownloads / mo
dictknife With conditions
PyPI · Utilities · released Jul 2025

dictknife provides utility functions for manipulating, querying, and transforming Python dictionaries, with optional support for loading data from files and command-line operations.

However, the aging maintenance status (405 days since last release) and sparse documentation suggest checking whether the specific dict operations you need are…

MITpure Python · 3.10+aging
79.5Kdownloads / mo
serpyco-rs Worth it
PyPI · Software Development · released Aug 2026

Serializes and deserializes Python dataclasses to/from dictionaries, JSON, or MessagePack, with built-in validation and support for nested types.

MITcompiled wheel · 3.10+
448.3Kdownloads / mo

See also databind · databind.json · pyserde · adaptix