Turn any JSON file into a beautiful, collapsible, bracket-free tree in your terminal.
Project description
jsonbonsai
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 fieldshint — no braces. - Arrays show as a named node with a
N itemshint — 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d09f1101135c745862c8206dca89490d734bfc74e7c23a132cb3daa82398539e
|
|
| MD5 |
5c1393732d7b6ad8f0bdffc14c650bde
|
|
| BLAKE2b-256 |
e7b8302cb2154fa8295da638f95565f6943ded658c226fab26ad5955b9f3457d
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
742a49b58c2a442f2416c4836ade961a2dfe2ef99a7dcdbffbbe9694836a0987
|
|
| MD5 |
fdb18a8e99c529a64cd3e82d0a980917
|
|
| BLAKE2b-256 |
16103137dc4073c09cef696a77ca9f232854a59b72ff45ca22e7d52d3d3e0add
|