Skip to content

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-viewer
root{4}
workspace"acme"
plan{4}
name"Team"
seats50
renews"2027-01-01"
users[7]
flags{3}
betatrue
ssofalse
regionnull
root
The code is part of Oxyn Pro

The preview stays free for everyone. Pro opens the code of every Pro component, screen, agent-app template, block and kit, plus the Pro CLI.

Get Pro

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.

Terminal
oxyn add json-viewer

Usage

Dioxus · rust
The code is part of Oxyn Pro

The preview is free. Pro opens the code of every Pro component, screen and template.

Get Pro

Examples

Tree

Two levels open; arrow keys, Enter, / to search.

root{4}
workspace"acme"
plan{4}
name"Team"
seats50
renews"2027-01-01"
users[7]
flags{3}
betatrue
ssofalse
regionnull
root
Code Pro
The code is part of Oxyn Pro

The preview is free. Pro opens the code of every Pro component, screen and template.

Get Pro

Search

Search “member”: matches open their branches.

root{4}
users[7]
1{5}
role"member"
2{5}
role"member"
4{5}
role"member"
5{5}
role"member"
root
Code Pro
The code is part of Oxyn Pro

The preview is free. Pro opens the code of every Pro component, screen and template.

Get Pro

Paged

Three per page with Show more.

root{4}
workspace"acme"
plan{4}
name"Team"
seats50
renews"2027-01-01"
users[7]
0{5}
id100
name"Ada"
age36
1{5}
id101
name"Lin"
age29
2{5}
id102
name"Sam"
age41
root
Code Pro
The code is part of Oxyn Pro

The preview is free. Pro opens the code of every Pro component, screen and template.

Get Pro

Bare

No search, no copy, root only.

root{4}
workspace"acme"
root
Code Pro
The code is part of Oxyn Pro

The preview is free. Pro opens the code of every Pro component, screen and template.

Get Pro

API reference

JsonViewer

PropTypeDefaultDescription
treerequiredJsonTree—Tree state.
searchablebooltrueShow the search field.
copyablebooltrueShow copy actions.
show_pathbooltrueShow the current path.
max_heightu32320Max height px.
labelString"JSON"Accessible name.
on_toggleEventHandler<String>—Toggle a branch.
on_queryEventHandler<String>—Query changed.
on_moreEventHandler<String>—Next page of a branch.
on_keyEventHandler<String>—Key: `up` · `down` · `left` · `right` · `home` · `end`, or select a row index.

Read from the Rust signature and doc comments.

Keyboard interactions

KeyAction
↓or↑Next / previous visible row
→or←Open or step in / close or go to parent
HomeorEndFirst / last row
EnterorSpaceToggle a branch or load the next page
⌘/Ctrl Cor⇧ for pathCopy 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 JsonViewer from oxyn_dioxus and include STATUS_INDICATOR_CSS plus the token stylesheet once.
  • A GPUI version exists: JsonViewerEl in oxyn_gpui.
  • Props to set first: tree.
  • Keep its states and timings as they ship; restyle it through the CSS variables rather than by hand.

Guides

Oxyn · 74 free components · 264 Pro components · 96 screens · 20 blocks · Dioxus and GPUI