flatdict
Python module for interacting with nested dicts as a single level dict with delimited keys.
What it is and what it does
FlatDict provides two dict subclasses—FlatDict and FlatterDict—that present nested dictionaries as a single flat level while preserving access to the original structure. When you wrap a nested dict, keys are automatically flattened using a delimiter (colon by default), so a path like `{'foo': {'bar': 'baz'}}` becomes accessible as `{'foo:bar': 'baz'}`. You can read and write using either the composite key or the nested path interchangeably.
FlatterDict extends this to sequences: lists and tuples are also flattened by converting indices to keys, so `{'list': ['a', 'b', 'c']}` becomes `{'list:0': 'a', 'list:1': 'b', 'list:2': 'c'}`. This is useful when you need to work with deeply nested or mixed structures as a flat key-value store—common in configuration handling, data transformation, or API response normalization.
Use it for:
- Normalize deeply nested JSON or config objects into a flat key-value store for easier iteration or lookup.
- Convert API responses with nested structures into a single-level dict for database storage or serialization.
- Flatten configuration hierarchies to pass as environment variables or command-line arguments.
- Transform nested data structures into a format suitable for CSV export or tabular processing.
- Simplify access patterns in code that needs to work with both flat and nested representations simultaneously.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Flattens nested dictionaries into single-level dicts with delimited composite keys, and optionally flattens lists and tuples by index.
Yes. This is a stable, well-maintained utility with zero dependencies, no known vulnerabilities, and a permissive license. Install it if you regularly work with nested dicts and need a lightweight, transparent way to flatten them. The low friction and broad Python version support make it a safe, practical choice.
Install
flatdict on PyPI
pip
pip install flatdictuv
uv add flatdictpoetry
poetry add flatdictInstalling flatdict
Before you install
Low friction: pure Python wheel with no runtime dependencies. Active maintenance with a recent release (2026-02-15) and a commit history through 2026-06-12. Supports Python 3.10 through 3.14 and PyPy.
License in practice
BSD-3-Clause (permissive): you can use, modify, and distribute this package freely in proprietary or open-source projects with minimal restrictions, provided you include the license notice.
Quickstart
pip install flatdict
import flatdict
value = flatdict.FlatDict({'foo': {'bar': 'baz'}})
print(value['foo:bar']) # 'baz'
print(value['foo']['bar']) # 'baz'
Package facts
| License | BSD-3-Clause (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 180 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,527,366/month — #3,811 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: flatdict-4.1.0-py3-none-any.whl
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
attrdictProvides dictionary-like objects that allow…
permissive · top 5,000 on PyPI
deflate-dictFlattens nested dictionaries into single-level…
permissive · top 15,000 on PyPI
flatten-jsonConverts nested JSON objects into flat…
permissive · top 5,000 on PyPI
json-normalizeRecursively flattens nested JSON-like…
permissive · top 15,000 on PyPI
magicattrProvides nested attribute access and…
permissive · top 5,000 on PyPI
flatten-dictConverts nested dictionaries into flat…
permissive · top 5,000 on PyPI
dictknifedictknife provides utility functions for…
permissive · top 15,000 on PyPI
json-flattenConverts nested JSON objects into flat…
permissive · top 15,000 on PyPI
dpathdpath lets you access, search, and modify…
permissive · top 5,000 on PyPI
querystring-parserParses URL query strings and POST data into…
permissive · top 5,000 on PyPI