Skip to main content

Turn any JSON file into a beautiful, collapsible, bracket-free tree in your terminal.

Project description

jsonbonsai

CI

Turn any JSON file into a beautiful, collapsible, bracket-free tree in your terminal.

No more squinting at {, }, [, ], and trailing commas. jsonbonsai reads a .json file and renders it as a navigable tree you can expand and collapse with the arrow keys — color-coded by type, with soft hints like 3 items instead of raw brackets.

Install (recommended)

git clone https://github.com/Arahman0115/jsonbonsai.git
pipx install ./jsonbonsai      # isolated, always on your PATH
# or
pip install ./jsonbonsai

Use

jsonbonsai sample.json        # open a file
cat sample.json | jsonbonsai  # or pipe JSON in

Keys

Key Action
/ Move between nodes
Enter On an object/array: expand / collapse. On a leaf: open the full value in a scrollable popup
/ Search keys and values (Enter to run, Esc to cancel)
n / N Jump to next / previous match
e Expand everything (disabled on very large files)
c Collapse everything
q Quit

Big files

The tree loads lazily — a node's children are only built when you expand it, so even multi-megabyte files open instantly instead of materializing every node up front. The header shows the total node count. Search scans the underlying data (not just what's on screen), then expands the tree to reveal each match, so it finds things in collapsed branches too. (e/expand-all is refused past ~20k nodes to avoid materializing the whole document at once.)

Inside the value popup: / to scroll, Esc / Enter / q to close. This is how you read long fields (e.g. embedded HTML narratives) in full without them being clipped to the terminal width.

If a value looks like HTML/XML (such as a FHIR text.div narrative), the popup opens in a formatted, syntax-highlighted view — indented and readable instead of one long line. Press f to toggle between the formatted view and the raw, byte-exact original value. Non-markup values open raw with no toggle. Formatting only changes the display; the underlying data is never modified.

Docker (optional)

The viewer is interactive, so it needs a TTY (-it) and your file mounted in:

docker build -t jsonbonsai .
docker run --rm -it -v "$PWD":/data jsonbonsai sample.json

How it simplifies the structure

  • Objects show as a named node with a N fields hint — no braces.
  • Arrays show as a named node with a N items hint — no brackets, index-labeled children.
  • Leaf values show as key: value, colored by type (string / number / bool / null).
  • Strings are shown without surrounding quotes for calmer reading.

Project layout

jsonbonsai/
├── jsonbonsai/
│   ├── cli.py        # argument parsing + JSON loading
│   ├── app.py        # the interactive Textual tree app
│   ├── render.py     # label styling / type colors / match highlight
│   └── formatting.py # HTML/XML pretty-printing for the value popup
├── tests/            # pytest suite
├── sample.json       # try it: jsonbonsai sample.json
├── Dockerfile        # optional container build
└── pyproject.toml

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jsonbonsai-0.1.1.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jsonbonsai-0.1.1-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file jsonbonsai-0.1.1.tar.gz.

File metadata

  • Download URL: jsonbonsai-0.1.1.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for jsonbonsai-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d09f1101135c745862c8206dca89490d734bfc74e7c23a132cb3daa82398539e
MD5 5c1393732d7b6ad8f0bdffc14c650bde
BLAKE2b-256 e7b8302cb2154fa8295da638f95565f6943ded658c226fab26ad5955b9f3457d

See more details on using hashes here.

File details

Details for the file jsonbonsai-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: jsonbonsai-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for jsonbonsai-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 742a49b58c2a442f2416c4836ade961a2dfe2ef99a7dcdbffbbe9694836a0987
MD5 fdb18a8e99c529a64cd3e82d0a980917
BLAKE2b-256 16103137dc4073c09cef696a77ca9f232854a59b72ff45ca22e7d52d3d3e0add

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page