Registry / serialization / databind

databind

JSON →
library4.5.5pypypi✓ verified 86d ago

Databind is a Python library, currently at version 4.5.4, designed for de-serializing and serializing Python dataclasses. Inspired by `jackson-databind`, it provides a flexible framework that understands most native Python types and dataclasses, primarily for configuration loading rather than high-performance use cases. It maintains a regular release cadence with recent updates fixing various serialization issues.

pip install databind
INSTALL
IMPORT
SIG · DATABIND
D
databind
serializationpythonv4.5.5
Install
2.5s avg
Import
128ms
Disk
18MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v4.5.5 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.133s · 19.8MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 2.5s · import 0.123s · 20MB
18MB installed
● package 18MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

dump
from databind.json import dump
from databind.core import dump
As of v4.5.0, `databind.core` and `databind.json` modules were merged into the top-level `databind` package.
load
from databind.json import load
from databind.core import load
As of v4.5.0, `databind.core` and `databind.json` modules were merged into the top-level `databind` package.

This example demonstrates basic serialization and deserialization of Python dataclasses to/from a dictionary (JSON-like structure) using `databind.json.dump` and `databind.json.load`.

from dataclasses import dataclass from databind.json import dump, load @dataclass class Server: host: str port: int @dataclass class Config: server: Server dict_payload = {"server": {"host": "localhost", "port": 8080}} # Deserialize loaded_config = load(dict_payload, Config) print(f"Loaded Config: {loaded_config}") assert loaded_config == Config(server=Server(host="localhost", port=8080)) # Serialize dumped_payload = dump(loaded_config, Config) print(f"Dumped Payload: {dumped_payload}") assert dumped_payload == dict_payload
Debug
Known issues
breakingThe `databind.core` and `databind.json` packages were merged directly into the top-level `databind` package in version 4.5.0. Imports should be updated from `databind.core.foo` or `databind.json.bar` to `databind.foo` or `databind.bar` respectively. This version also dropped support for Python 3.6 and 3.7.
fix
Update import statements: e.g., `from databind.json import dump` instead of `from databind.json import dump`.
affects: >=4.5.0
gotchaDatabind does not assume `Any` for missing type parameters in generics. If a generic type (e.g., `list`) is used without a specific type hint (e.g., `list[str]`), a `NoMatchingConverter` error will be raised during deserialization.
fix
Always specify type parameters for generic types, e.g., `field: list[YourType]`.
affects: All versions
gotchaBeware of inherited Union settings via Method Resolution Order (MRO), which historically led to `RecursionError` during serialization/deserialization. This was a known issue with complex inheritance hierarchies involving `Union` types.
fix
Upgrade to `databind` version 4.5.4 or newer to fix the `RecursionError` related to Union inheritance.
affects: <4.5.4
gotchaFields from generic dataclasses with unspecified `TypeVar`s might not be serialized correctly. For instance, a generic dataclass `MyClass(Generic[T])` where `T` is not bound in a subclass can lead to `no deserializer for TypeHint(~T)`.
fix
Create a dedicated subclass that binds the `TypeVar` to a concrete type or another bounded `TypeVar` (e.g., `@dataclass class MySpecificClass(MyClass['MySpecificClass']): pass`).
affects: All versions
Errors
Common errors & fixes
databind.core.converter.NoMatchingConverter: no deserializer for `TypeHint(~T_Page)` and payload of type `dict`
A generic type (e.g., `list` or a custom generic dataclass) was used in a type hint without specifying its type parameters (e.g., `list[str]`), causing databind to not know how to deserialize the inner type.
fix
Explicitly define the type parameters for generic types. For example, change `list` to `list[YourType]` or `MyClass` to `MySpecificClass(MyClass['MySpecificClass'])`.
RecursionError: maximum recursion depth exceeded
In versions prior to 4.5.4, complex inheritance chains combined with `Union` types could lead to infinite recursion during converter lookup due to an issue with MRO and Union settings.
fix
Upgrade to `databind` version 4.5.4 or newer. If upgrading is not immediately possible, consider simplifying `Union` definitions or inheritance structures.
databind.core.converter.ConversionError: Unknown field 'extra_key'
The input payload contains keys that are not defined as fields in the target dataclass, and the `ExtraKeys` setting is not enabled to allow or record these additional fields.
fix
Use the `databind.core.ExtraKeys` setting. Apply `@ExtraKeys()` to the dataclass, use `Annotated[FieldType, ExtraKeys()]` for a specific field, or pass `settings=[ExtraKeys()]` to the `load()` function.
Upgrade
Version history
4.5.5latest on PyPI · released May 22, 2026
Audit
Dependencies
PythonrequiredCompatible with Python 3.8 and newer versions.
Agent activity
20 hits · last 30 days
node
16
Amazon
1
OpenAI (training)
1
Resources
databind — pip install databind · libregistry