python-box
Advanced Python dictionaries with dot notation access
What it is and what it does
Box is a dict subclass that makes nested dictionary data accessible via dot notation instead of bracket syntax. When you create a Box, any nested dicts are automatically converted to Box objects and lists to BoxList objects, allowing you to write `box.key.nested_key` instead of `box['key']['nested_key']`. Keys with special characters or spaces are normalized to valid Python identifiers, making otherwise inaccessible keys safe to reference as attributes.
The package is designed as a transparent drop-in replacement for dict with optional customization. It supports initialization the same way as dict (keyword args, iterables, or other dicts), includes helper methods to convert back to plain dicts or serialize to JSON, YAML, TOML, or msgpack, and optionally uses Cython compilation for performance on supported platforms. It has no external runtime dependencies by default, though optional extras like ruamel.yaml or tomli_w can be installed for format support.
Use it for:
- Parse and traverse JSON or API responses using dot notation instead of repeated bracket indexing
- Convert configuration files (YAML, TOML) into objects with attribute access for cleaner code
- Build nested data structures programmatically while maintaining dict compatibility with existing code
- Simplify data access in scripts where bracket syntax becomes verbose or hard to read
- Serialize Python objects back to JSON or other formats while preserving structure
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Box wraps Python dictionaries to enable dot-notation attribute access on keys, automatically converting nested dicts and lists while remaining a dict subclass.
Yes. Box is stable, actively maintained, has zero known vulnerabilities, installs with no dependencies, and solves a genuine readability problem for nested dict access. The MIT license imposes no restrictions. Install it if you work regularly with nested dicts or config data and want cleaner syntax; skip it only if you prefer strict dict semantics or have a strong style preference against attribute access.
Install
python-box on PyPI
pip
pip install python-boxuv
uv add python-boxpoetry
poetry add python-boxInstalling python-box
Before you install
Low friction install with no runtime dependencies. Actively maintained with recent releases; supports Python 3.9 and newer including current versions. Optional Cython optimization available for faster large-dataset handling on supported platforms.
License in practice
MIT license permits unrestricted use, modification, and distribution in both open-source and commercial projects with minimal obligations.
Quickstart
from box import Box
movie_box = Box({"Robin Hood: Men in Tights": {"imdb stars": 6.7, "length": 104}})
print(movie_box.Robin_Hood_Men_in_Tights.imdb_stars) # 6.7
Verify before relying
- Whether Cython optimization is automatically applied on x86_64 systems or requires manual installation
- Performance characteristics for very large nested structures beyond the stated 10x speedup claim
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 174 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 7,253,207/month — #1,762 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: python_box-7.4.1-py3-none-any.whl
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI 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
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
super-collectionsConverts nested JSON and YAML data into Python…
permissive · top 5,000 on PyPI
mo-dotsProvides null-safe dot-notation access to…
copyleft · top 15,000 on PyPI
magicattrProvides nested attribute access and…
permissive · top 5,000 on PyPI
easydictEasyDict wraps Python dictionaries to allow…
copyleft · top 5,000 on PyPI
jsonasobj2Converts JSON data into Python objects with…
permissive · top 15,000 on PyPI
attrdictProvides dictionary-like objects that allow…
permissive · top 5,000 on PyPI
prodictProdict wraps Python dictionaries to allow…
permissive · top 15,000 on PyPI
munchMunch provides a dictionary subclass that…
permissive · top 5,000 on PyPI
flatdictFlattens nested dictionaries into single-level…
permissive · top 5,000 on PyPI
dotmapDotMap is a dict subclass that lets you access…
permissive · top 5,000 on PyPI