Skip to content
English
JSON viewer comes with Pro. Its preview shows once you unlock it.

How it works

The value is flattened into a list of nodes once, and only the open ones render, as 28px monospace rows. Each level indents 18px; indent guides are one repeating gradient per row, not one element per level. Strings, numbers, booleans and null take chart colours mixed toward the text colour, so they stay readable in both themes. A folded branch shows a small badge with its size. Search marks hits with a warm highlight and a dot in the gutter and opens every branch that holds one, without overriding branches the user toggled. Hovering a row fades in a “Copy path” chip that writes a JavaScript-style path, and turns into a check for 1.4 seconds.

Use it for

  • API consoles, webhook logs and debug panels where people inspect a payload.
  • Settings or records stored as JSON that people need to read, not edit.

Look elsewhere when

  • Editing JSON: use a code editor with validation.
  • Very large documents (tens of thousands of nodes): page or virtualise them.

Usage

import { JsonViewer } from './JsonViewer.jsx'

export function ResponsePanel({ body, query }) {
  return (
    <JsonViewer
      data={body}
      rootLabel="response"
      label="Response body"
      search={query}
      defaultExpandDepth={2}
      onCopyPath={(path) => console.info('copied', path)}
    />
  )
}

Props

PropTypeDefaultWhat it does
dataunknown—Any JSON-compatible value.
rootLabelstring'$'Name of the root, and the start of every copied path (response.files[0].title).
defaultExpandDepthnumber1Levels open at first. The user's own toggles win afterwards.
searchstring''Case-insensitive text to mark in keys and values; branches holding a match open, and a count appears above the tree.
guidesbooleantrueA hairline per indent level.
onCopyPath(path: string, value) => void—Called when a path is copied; the path is also written to the clipboard.
label / labelsstring / { copy, copied, keys(n), items(n), matches(n), announceCopied(path) }'JSON'Accessible name of the tree and every built-in string.

Accessibility

  • The tree uses role tree and treeitem with aria-level, aria-setsize, aria-posinset and aria-expanded; one row is in the Tab order.
  • Up and Down move between rows, Right opens a branch or enters it, Left closes it or goes to the parent, Home and End jump, Enter or Space toggles.
  • C copies the focused row's path and a polite live region announces it; the mouse chip is hidden from assistive technology to avoid a duplicate control.
  • The match count is a polite live region. Types are told apart by quotes and literals as well as colour.
  • Reduced motion removes the chevron turn and the chip slide.

Motion

Chevron: 220ms turn on the reveal curve. Copy chip: 160ms fade with a 220ms spring slide.

Add it to your project

Pro members copy a prompt and their coding agent installs the source, the same way as the free components.

JsonViewer.jsxjson-viewer.csstokens.cssREADME.md

Both files install together. The stylesheet reads the design tokens in tokens.css and carries fallbacks, so it also works alone.

Data display
Code diff comes with Pro. Its preview shows once you unlock it.
Flip countdown comes with Pro. Its preview shows once you unlock it.