skillfed

python-box

Advanced Python dictionaries with dot notation access

python-box v7.4.1 7.3M downloads/30d#1,762 on PyPI2,831
Permissive license MIT Active released

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-box

uv

uv add python-box

poetry

poetry add python-box

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseNatural Language :: EnglishOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: Implementation :: CPythonTopic :: Software DevelopmentTopic :: Software Development :: Libraries :: Python ModulesTopic :: Utilities

Tags

dot notation dictionary accessdict attribute accessnested dict traversalpython dict wrapperkey-value attribute syntaxdict to object conversionsafe key access
dict-wrapperdata-access

More Software Development packages