deepmerge
A toolset for deeply merging Python dictionaries.
What it is and what it does
deepmerge handles the problem of combining nested Python data structures—dictionaries, lists, and sets—where simple assignment or shallow merging would lose data or overwrite values. It provides both a ready-to-use merger (always_merger) that applies sensible defaults and a Merger class for defining custom merge strategies per type. You specify how lists should combine (append, extend, or replace), how dicts should merge, how sets should combine, and what to do when types conflict or don't match any rule.
The package is lightweight, depends only on typing_extensions, and supports Python 3.8 and later. It's useful in configuration management, data aggregation, and any workflow where you need to combine nested structures without losing information from either source.
Use it for:
- Merge configuration dictionaries from multiple sources (defaults, environment, user config) without losing nested settings.
- Combine API responses or JSON documents with overlapping keys while preserving list elements from both sources.
- Aggregate nested data from multiple files or database records into a single structure.
- Build custom merge logic for domain-specific data types using the Merger class with type-specific strategies.
- Handle YAML or JSON config merging in deployment or build tools where deep nesting is common.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Merges nested Python data structures (dicts, lists, sets) with customizable strategies for handling conflicts and type-specific behavior.
Yes. deepmerge is production-stable (Development Status 5), actively maintained, has no known vulnerabilities, and solves a common problem with minimal dependencies and friction. Install it if you regularly merge nested dicts or need flexible control over how conflicts are resolved.
Install
deepmerge on PyPI
pip
pip install deepmergeuv
uv add deepmergepoetry
poetry add deepmergeInstalling deepmerge
Before you install
Low install friction with a single pure-Python dependency (typing_extensions). Active maintenance: last release 53 days ago, repository not archived, recent commits present.
License in practice
MIT License (permissive) places no restrictions on use, modification, or distribution in proprietary or open-source projects.
Quickstart
pip install deepmerge
from deepmerge import always_merger
base = {"foo": ["bar"]}
next_dict = {"foo": ["baz"]}
result = always_merger.merge(base, next_dict)
# result: {'foo': ['bar', 'baz']}
Package facts
| License | MIT Licence (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — typing_extensions |
| Maintenance | actively maintained — 53 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 9,811,870/month — #1,498 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: deepmerge-2.1.0-py3-none-any.whl
Tags
More Application Frameworks packages
FastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
textualTextual is a Python framework for building…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
mcpBuild and connect to Model Context Protocol…
permissive · top 1,000 on PyPI
WerkzeugWerkzeug is a WSGI utility library providing…
permissive · top 1,000 on PyPI
dict-recursive-updateRecursively merges one dictionary into another,…
permissive · top 15,000 on PyPI
hydratersMerges nested Python dictionaries efficiently…
unclear · top 15,000 on PyPI
jsonmergeMerges multiple JSON documents into a single…
permissive · top 5,000 on PyPI
merge3Implements 3-way merge of text sequences,…
copyleft · top 15,000 on PyPI
mergedeepMerges nested dictionaries recursively,…
permissive · top 1,000 on PyPI
flatdictFlattens nested dictionaries into single-level…
permissive · top 5,000 on PyPI
nested-lookupProvides functions to search, update, delete,…
permissive · top 15,000 on PyPI
pytest-html-mergerMerges multiple pytest HTML reports generated…
unclear · top 15,000 on PyPI
datadiffGenerates human-readable diffs of Python data…
permissive · top 15,000 on PyPI
dpathdpath lets you access, search, and modify…
permissive · top 5,000 on PyPI