Skip to main content

anyjsonviewer

An anywidget wrapper around @textea/json-viewer, giving you an interactive, collapsible JSON viewer inside Jupyter, JupyterLab, VS Code, Marimo, or any other frontend that supports Jupyter widgets.

Installation

pip install anyjsonviewer

Or with uv:

uv add anyjsonviewer

Usage

from anyjsonviewer import JsonViewer

JsonViewer(
    data={
        "name": "anyjsonviewer",
        "tags": ["json", "viewer", "anywidget"],
        "nested": {"count": 3, "ok": True},
    },
    theme="dark",
)

Traits

All props are synced traits, so you can update them from Python and the view re-renders live:

Trait Type Default Description
data any JSON-serializable None The data to display.
root_name str | None "root" Label for the root node. None hides it.
theme str "light" "light", "dark", or "auto".
class_name str | None None Custom CSS class on the root element.
style dict | None None Inline CSS styles for the root element.
indent_width int 3 Indentation width for nested objects.
default_inspect_depth int 5 Depth to auto-expand on first render. Set to 0 to fully collapse.
max_display_length int 30 Hide items in arrays/objects past this count.
group_arrays_after_length int 100 Group arrays into bracketed chunks after this length.
collapse_strings_after_length int 50 Truncate long strings; click to expand.
object_sort_keys bool False Sort object keys alphabetically.
quotes_on_keys bool True Wrap keys in quotes.
display_data_types bool True Show type annotations next to values.
display_size bool True Show length of arrays/objects.
display_comma bool True Show trailing commas.
highlight_updates bool True Briefly highlight values when they change.
enable_clipboard bool False Show copy-to-clipboard buttons.
enable_add bool False Show "add" buttons on objects/arrays.
enable_delete bool False Show "delete" buttons on items.
editable bool False Allow inline editing of values.

When editable, enable_add, or enable_delete are on, edits round-trip through the data trait — change something in the UI and the new value becomes visible from Python.

w = JsonViewer(data={"a": 1})
w.theme = "dark"         # live update
w.data = {"a": 1, "b": 2}

Using with Marimo

Marimo's mo.ui.anywidget() wrapper exposes .value as a dict of every synced trait, so to get just the JSON you'd write wrapper.value["data"]. You can also keep a reference to the underlying widget and use it directly:

viewer = JsonViewer(data=my_data)
ui = mo.ui.anywidget(viewer)
ui                  # render in a cell
viewer.data         # ← just the JSON, same as in Jupyter
ui.value["data"]    # ← Marimo wrapper-native equivalent

Development

The widget's JavaScript lives in js/index.jsx and is bundled with esbuild into src/anyjsonviewer/static/widget.js.

# Install Python deps
uv sync

# Install JS deps
npm install

# One-off build
npm run build

# Watch mode (pair with ANYWIDGET_HMR=1 in your notebook)
npm run dev

Building the wheel automatically runs the JS build via a custom Hatch hook:

uv build

To skip the JS build step (e.g. in CI where you've already built the bundle), set ANYJSONVIEWER_SKIP_JS_BUILD=1.

License

MIT

Release files for anyjsonviewer 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for anyjsonviewer 0.2.0
File Size Uploaded
anyjsonviewer-0.2.0.tar.gz 114.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for anyjsonviewer 0.2.0
File Interpreter ABI Platform
anyjsonviewer-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 212.9 kB

Release files / anyjsonviewer-0.2.0.tar.gz

Download URL anyjsonviewer-0.2.0.tar.gz
Size 114.3 kB
Tags Source
SHA-256 checksum
How to use checksums
86054430a7ff60a5c516b8382475455ff10588b0462c9eee502b61ee195f4cfa
BLAKE2b-256 checksum
How to use checksums
2d58bd8489af3217fa29ec2f8bc4f8cddd5f3364081df4d995a703c08b619b6c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 11, 2026.

Transparency log

Release files / anyjsonviewer-0.2.0-py3-none-any.whl

Download URL anyjsonviewer-0.2.0-py3-none-any.whl
Size 98.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d17d9c7a21b0836b34641fb40204449e6de84941af8d0585486822c5961e5c7b
BLAKE2b-256 checksum
How to use checksums
3ab12f6f4ea590037b9c31612759a12a537aa6f339ebc5e6fa5460ff590af5f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 11, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page