JSON viewer
A collapsible tree of JSON with copy and search.
invoice.payment_succeeded
- { 7 keys }
- id"evt_1Q9x"
- object"event"
- livemodefalse
- created1792487640
- type"invoice.payment_succeeded"
- data{ 1 key }
- recent[ 120 items ]
$When to use
- Inspecting an API response or payload.
When not to use
- The data is not JSON.
Installation
terminal
pnpm dlx shadcn@latest add @caliper/json-viewer
Adds its 5 files to components/ui/, each with its own stylesheet, and installs their packages. Pro installs with your access token, set up once per project. See Pro access. The first part also adds Caliper UI’s tokens; import them once as in Installation.
API reference
JsonViewer
5 props
PropTypeDefaultDescription
label *string—
data *unknown—
defaultDepthnumber1Levels open at first.
querystring""Highlights matching keys and values and opens the branches that hold them.
classNamestring—
Keyboard
- ↓
- Moves to the next item or value.
- ↑
- Moves to the previous item or value.
- Home
- Jumps to the first item or the minimum.
- End
- Jumps to the last item or the maximum.
- →
- Moves to the next item or value.
- ←
- Moves to the previous item or value.
- Enter
- Activates the focused control.
- Space
- Activates the focused control.
Accessibility
It exposes tree, treeitem and status semantics, with aria-label, aria-level, aria-setsize, aria-posinset, aria-expanded and aria-selected kept in step with state. Changes that matter are announced through a live region.
Notes for AI
Give your coding assistant this page as Markdown instead of screenshots: the props, keyboard and examples in one file.
/docs/components/json-viewer.mdThe index of every part is at /llms.txt.