skillfed

json-flatten

Python functions for flattening a JSON object to a single dictionary of pairs, and unflattening that dictionary back to a JSON object

json-flatten v0.3.1 538.0K downloads/30d#6,117 on PyPI56
Permissive license Apache License, Version 2.0 AGING released

What it is and what it does

json-flatten provides two core functions: flatten() converts a nested JSON dictionary into a single-level dictionary with dot-notation keys and type suffixes (e.g., `user.age$int`), and unflatten() reverses the process. It preserves type information for integers, floats, booleans, nulls, and empty containers through suffix markers, and represents list indices using bracket notation like `items.[0]`.

The package is designed for scenarios where you need to represent JSON as HTML form data or URL query parameters—contexts where nested structures don't map naturally. It handles arbitrarily nested objects and lists, including matrices and mixed nesting patterns, all without external dependencies.

Use it for:

  • Serialize nested JSON to HTML form fields while preserving type information for round-trip conversion.
  • Encode complex JSON structures as URL query string parameters for API requests.
  • Flatten configuration objects for storage in flat key-value databases or environment variables.
  • Convert JSON payloads to flat dictionaries for compatibility with legacy systems expecting single-level data.
  • Debug and inspect deeply nested JSON by viewing all paths and values in a single flat view.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Converts nested JSON objects into flat key-value dictionaries and back, preserving types using suffix notation, useful for HTML forms or query string parameters.

Yes, if you need JSON flattening with type preservation and have no special Python version requirements. The zero-dependency design and low install friction make it straightforward to add. However, the aging maintenance status (706 days since last release) means you should verify it handles your specific JSON structures before relying on it in production; consider forking or monitoring the repository if you need ongoing support.

Install

json-flatten on PyPI

pip

pip install json-flatten

uv

uv add json-flatten

poetry

poetry add json-flatten

Installing json-flatten

Before you install

Low friction: no runtime dependencies, pure Python wheel. Aging maintenance status—last release was 706 days ago and repository shows no recent activity, though it remains unarchived.

License in practice

Apache License 2.0 is permissive; you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.

Quickstart

pip install json-flatten

import json_flatten
flat = json_flatten.flatten({"foo": {"bar": [1, True, None]}})
original = json_flatten.unflatten(flat)

Verify before relying

  • Whether the package handles edge cases like circular references or very deeply nested structures.
  • Performance characteristics on large or complex JSON structures.
  • Python version compatibility (requires_python is unspecified in metadata).

Package facts

License Apache License, Version 2.0 (permissive)
Python support not specified
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance aging — 706 days since the last release
Last repo commit
First released
Downloads 538,007/month — #6,117 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: json_flatten-0.3.1-py3-none-any.whl

Tags

flatten json to dictionaryjson to flat key-value pairsunflatten dictionary to jsonjson form serializationnested object flatteningquery string json encodingtype-preserving json flatten
json-serializationdata-transformation

More Utilities packages