JSON view

Shows structured data as a foldable tree.

Toolbar

  • {
    "tool": "issue_refund",
    "ok": true,
    "input": {
    "order": "ord_4812",
    "amount": 42.5,
    "currency": "usd",
    "reason": "Item arrived damaged"
    "output": {
    "refund": "re_demo_91c0",
    "status": "succeeded",
    "note": "The customer wrote on Oct 11 that the box arrived crushed and the lamp inside w…
    "warnings": [],
    "trace": null
    Path$

    truedefault

  • Run
    {
    "run": "run_01J9ZKQX8M2V4E7Q",
    "agent": "support-agent",
    "status": "ok",
    "tokens": 2418,
    "tags": [
    0: "refund",
    1: "eval"

    false

Usage

When to use it
Use
A tool result, a run payload or a span's attributes that people search and drill into.
Use
Someone needs the path to a value for code, a jq filter or a bug report.
Not for
A file or a snippet to read top to bottom. Use Code block.
Not for
A handful of named fields about one thing. Use Data list.

Rules

6 rules
Never
Show structured output as JSON.stringify in a CodeBlock when people will search or fold it. Because a flat dump of 400 lines has no folding, no search and no path, so finding steps[2].ms means counting brackets.
Must
Name the tree with label: what the data is, such as "issue_refund result". Because label names the tree, the search field and the scroll region, and "JSON" alone does not say which of three results it is.
Should
Open two levels by default, and set defaultExpandDepth={1} for payloads over a few hundred rows. Because the top keys tell what is inside, and a fully open large payload buries them.
Never
Colour keys, strings or numbers with hues. Because colour means status in Glaze, and JSON view shares Code block's ink steps.
Must
Pass the parsed value as data, not a JSON string. Because a string renders as one long string row, with nothing to fold or search inside it.
Should
Keep maxRows at about 16 inside a card; the tree scrolls past it. Because an open payload can run to hundreds of rows and push the rest of the card away.

Accessibility

4 checks
The tree follows the WAI-ARIA tree pattern: role="tree", treeitems with aria-level and aria-expanded, one tab stop.
Search reports "2 of 5" or "No matches" in a polite live region.
When the tree overflows, its scroll box takes a tab stop so the keyboard can scroll it.
Copy and path copy say Copied once in a status region.

Keyboard

7 keys
Arrow Up and Down
Move between rows.
Arrow Right
Opens a branch, or moves into it.
Arrow Left
Closes a branch, or moves to its parent.
Home and End
Move to the first and last row.
Enter or Space
Toggles a branch, or unfolds a long string.
Enter in search
Steps to the next match; Shift+Enter steps back.
Escape in search
Clears the search.

Edge cases

5 edge cases
String over 120 characters
Folds to 80 with a "+n chars" button.
Empty object or array
Shows {} or [] with nothing to open.
Key with spaces
The path writes it in brackets: $["user agent"].
Right to left page
The tree stays left to right.
Narrow at 390
Rows scroll sideways inside the surface.

API

7 props
data
unknown
label
string default 'JSON'
defaultExpandDepth
number default 2
toolbar
boolean default true
copy
boolean default true
path
boolean default toolbar
maxRows
number default 16

Tokens

13 tokens
--code-surface
var(--paper)
--line-faint
rgb(5 5 5 / 0.06)
--line-control
rgb(5 5 5 / 0.15)
--radius-overlay
10px
--radius-tag
6px
--type-code-block
400 12px/20px var(--font-mono)
--type-caption
400 12px/1.35 var(--font-sans)
--text-1
rgb(5 5 5 / 0.80)
--text-2
rgb(5 5 5 / 0.60)
--hover
rgb(5 5 5 / 0.06)
--pressed
rgb(5 5 5 / 0.10)
--control-sm
26px
--control
32px

Install

For your coding agent

GitHub

Please star me pookie

141

A new design system every week

Leave your email before you copy the prompt.