JSON viewerPro
A collapsible JSON tree with search, paging for long arrays, copy value or path, the current path under the tree and full keyboard moves.
oxyn add json-viewerThe preview stays free for everyone. Pro opens the code of every Pro component, screen, agent-app template, block and kit, plus the Pro CLI.
Rendered from Rust at build time · goes live when visible
When to use
- A collapsible JSON tree (a small built-in parser, no dependency): branches open to with_depth(n) on first render (1 opens the root), search filters to matches and opens their branches, long arrays and objects page (page, default 50) with Show n more, each row copies its value or path (Copy value text is the real value via value_text), the current row's path shows under the tree with a Copied status, and the keyboard moves through it.
When not to use
- A launch countdown with digits that roll per unit, a compact one-line variant, hours absorbing days when days are hidden, and a live state with a pulsing dot at zero: use Countdown instead.
- A total that moves clearly: use Animated counter instead.
- A word-level diff for prose: use Inline Diff instead.
Installation
JSON viewer is part of Oxyn Pro; the preview is free. Pro items install with the oxyn CLI once your licence is signed in; until then Pro members copy the code from this page.
oxyn add json-viewerUsage
The preview is free. Pro opens the code of every Pro component, screen and template.
Examples
Tree
Two levels open; arrow keys, Enter, / to search.
Code Pro
The preview is free. Pro opens the code of every Pro component, screen and template.
Search
Search “member”: matches open their branches.
Code Pro
The preview is free. Pro opens the code of every Pro component, screen and template.
Paged
Three per page with Show more.
Code Pro
The preview is free. Pro opens the code of every Pro component, screen and template.
Bare
No search, no copy, root only.
Code Pro
The preview is free. Pro opens the code of every Pro component, screen and template.
API reference
JsonViewer
| Prop | Type | Default | Description |
|---|---|---|---|
treerequired | JsonTree | — | Tree state. |
searchable | bool | true | Show the search field. |
copyable | bool | true | Show copy actions. |
show_path | bool | true | Show the current path. |
max_height | u32 | 320 | Max height px. |
label | String | "JSON" | Accessible name. |
on_toggle | EventHandler<String> | — | Toggle a branch. |
on_query | EventHandler<String> | — | Query changed. |
on_more | EventHandler<String> | — | Next page of a branch. |
on_key | EventHandler<String> | — | Key: `up` · `down` · `left` · `right` · `home` · `end`, or select a row index. |
Read from the Rust signature and doc comments.
Keyboard interactions
| Key | Action |
|---|---|
| ↓or↑ | Next / previous visible row |
| →or← | Open or step in / close or go to parent |
| HomeorEnd | First / last row |
| EnterorSpace | Toggle a branch or load the next page |
| ⌘/Ctrl Cor⇧ for path | Copy the current value or path |
| / | Focus search; Enter / ⇧Enter next / previous match; Esc clears; ↓ back to the tree |
Accessibility
- role=tree with treeitems (aria-level, aria-expanded, aria-selected) and aria-activedescendant.
- Copy confirmations are a status.
From the spec
- role=tree with treeitem rows (aria-level, aria-expanded, aria-selected) and aria-activedescendant; the tree has an accessible name (
label).
Motion & interaction
Timing
- Reduced motion: no entrance rise or row stagger, no shimmer (static muted text), chevrons and the card morph jump to their end state.
Responsive behaviour
- Values truncate; the tree scrolls inside max height.
Edge cases (spec)
- Values truncate; the tree scrolls inside
max_height.
Notes for AI
- Import
JsonViewerfromoxyn_dioxusand includeSTATUS_INDICATOR_CSSplus the token stylesheet once. - A GPUI version exists:
JsonViewerElinoxyn_gpui. - Props to set first:
tree. - Keep its states and timings as they ship; restyle it through the CSS variables rather than by hand.