dacite

Python dataclass deserialization library — converts dicts/JSON into typed Python dataclasses with validation. dacite features: from_dict(DataClass, data_dict) converts nested dicts to dataclasses, strict=True rejects unknown keys, type_hooks for custom type conversion ({str: str.strip}), forward references support, Union type handling, Optional detection, nested dataclass support, and config object for transformation rules. Fills the gap between Python dataclasses (no built-in deserialization) and heavier ORMs/validators like Pydantic — useful for agent code parsing structured LLM responses or API payloads into typed dataclasses.

Evaluated Mar 06, 2026 (0d ago) v1.x
Homepage ↗ Repo ↗ Developer Tools python dacite dataclasses deserialization type-safety json validation
⚙ Agent Friendliness
63
/ 100
Can an agent use this?
🔒 Security
94
/ 100
Is it safe for agents?
⚡ Reliability
81
/ 100
Does it work consistently?

Score Breakdown

⚙ Agent Friendliness

MCP Quality
--
Documentation
80
Error Messages
75
Auth Simplicity
98
Rate Limits
98

🔒 Security

TLS Enforcement
95
Auth Strength
95
Scope Granularity
92
Dep. Hygiene
90
Secret Handling
95

Local deserialization library — no network access. dacite doesn't sanitize input data — validate agent API responses before from_dict if data comes from untrusted sources. strict=True prevents unexpected data injection via unknown keys.

⚡ Reliability

Uptime/SLA
80
Version Stability
82
Breaking Changes
82
Error Recovery
80
AF Security Reliability

Best When

Your Python agent code uses dataclasses (not Pydantic) and needs clean dict-to-dataclass conversion for LLM response parsing, API payloads, or config loading without pulling in Pydantic.

Avoid When

You need validation rules, serialization, high performance, or are already using Pydantic — dacite is specifically for dataclass deserialization only.

Use Cases

  • Agent structured LLM output parsing — @dataclass class AgentPlan: steps: List[str]; tool: str; confidence: float; plan = from_dict(AgentPlan, llm_json_response) — converts LLM JSON output into typed dataclass; agent code works with typed object not raw dict
  • Agent API response typing — @dataclass class SearchResult: url: str; title: str; snippet: str; results = [from_dict(SearchResult, r) for r in api_response['items']] — type-safe search results without Pydantic overhead; agent tool responses deserialized to dataclasses
  • Agent config loading — @dataclass class AgentConfig: model: str; temperature: float; max_tokens: int = 2048; config = from_dict(AgentConfig, yaml.safe_load(config_file)) — YAML/JSON config files loaded as typed dataclasses; IDE autocomplete and type checking on agent config
  • Nested agent data structures — @dataclass class Task: agent: Agent; tools: List[Tool]; task = from_dict(Task, raw_data, Config(strict=True)) — recursive dataclass deserialization; strict=True catches unexpected API response fields for agent data validation
  • Type coercion for agent data — from_dict(Agent, data, Config(type_hooks={datetime: datetime.fromisoformat})) converts ISO string timestamps to datetime objects; agent data from APIs with string dates converted without manual parsing

Not For

  • Full validation with error messages — dacite raises DaciteError but doesn't provide Pydantic-style field-level validation errors; for agent data with complex validation rules use Pydantic
  • Schema serialization/deserialization — dacite only deserializes (dict→dataclass); for dict output from dataclass use dataclasses.asdict(); for full schema use Pydantic or marshmallow
  • Performance-critical deserialization — dacite uses Python reflection; for high-throughput agent deserialization use msgspec or cattrs which are C-optimized

Interface

REST API
No
GraphQL
No
gRPC
No
MCP Server
No
SDK
Yes
Webhooks
No

Authentication

Methods: none
OAuth: No Scopes: No

No auth — local Python library.

Pricing

Model: open_source
Free tier: Yes
Requires CC: No

dacite is MIT licensed, maintained by Konrad Halas. Free for all use.

Agent Metadata

Pagination
none
Idempotent
Full
Retry Guidance
Not documented

Known Gotchas

  • Optional fields require default value — @dataclass class Agent: name: str; status: Optional[str] = None; dacite doesn't auto-provide None for Optional without default; agent dataclasses with Optional fields must have default=None or from_dict raises MissingValueError if key absent in dict
  • List of dataclasses requires explicit type annotation — tools: List[Tool] works; tools: list works but gives List[Any] without type checking; agent dataclasses must use fully typed annotations for dacite to recursively deserialize nested dataclasses; bare list type skips nested deserialization
  • strict=True required to catch LLM response drift — without strict mode, extra keys in dict (from LLM response adding new fields) are silently ignored; agent code using dacite without strict=True misses LLM response schema changes; use strict=True in agent parsing and catch DaciteError to detect schema drift
  • Union types require explicit ordering — Union[str, int] tries str first, then int; Union[int, str] tries int first; agent data with ambiguous Union types (API returning either string or number) must order Union by most specific type first; wrong order causes wrong type coercion
  • No forward reference support in older Python — @dataclass class Task: agent: 'Agent' (string annotation for forward ref) requires from __future__ import annotations or from_dict with types.get_type_hints(); agent code with circular dataclass references needs explicit type resolution in from_dict call
  • from_dict doesn't validate constraint logic — dacite checks types not values; from_dict(Agent, {'confidence': 1.5}) succeeds even if confidence should be 0.0-1.0; agent data validation beyond types requires explicit post-init __post_init__ in dataclass or pre-validation before from_dict

Alternatives

Full Evaluation Report

Comprehensive deep-dive: security analysis, reliability audit, agent experience review, cost modeling, competitive positioning, and improvement roadmap for dacite.

AI-powered analysis · PDF + markdown · Delivered within 30 minutes

$99

Package Brief

Quick verdict, integration guide, cost projections, gotchas with workarounds, and alternatives comparison.

Delivered within 10 minutes

$3

Score Monitoring

Get alerted when this package's AF, security, or reliability scores change significantly. Stay ahead of regressions.

Continuous monitoring

$3/mo

Scores are editorial opinions as of 2026-03-06.

5229
Packages Evaluated
26151
Need Evaluation
173
Need Re-evaluation
Community Powered