skillfed

deepmerge

A toolset for deeply merging Python dictionaries.

deepmerge v2.1.0 9.8M downloads/30d#1,498 on PyPI211
Permissive license MIT Licence Active released

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 deepmerge

uv

uv add deepmerge

poetry

poetry add deepmerge

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Typing :: Typed

Tags

merge nested dictionariesdeep merge python dictscombine nested data structuresrecursive dictionary mergemerge lists and dicts togethercustom merge strategieshandle nested dict conflicts
data-structuresconfiguration-management

More Application Frameworks packages