Ir al contenido
Español
Visor de JSON viene con Pro. La vista previa aparece al desbloquearlo.

Cómo funciona

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.

Úsalo para

  • 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.

Busca otra opción cuando

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

Uso

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)}
    />
  )
}

Propiedades

PropiedadTipoPor defectoQué hace
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.

Accesibilidad

  • 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.

Movimiento

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

Añádelo a tu proyecto

Los miembros Pro copian un prompt y su agente de programación instala el código, igual que con los gratuitos.

JsonViewer.jsxjson-viewer.csstokens.cssREADME.md

Los dos archivos se instalan juntos. La hoja de estilos lee las variables de tokens.css y lleva valores de reserva, así que también funciona sola.

Datos
Diferencias de código viene con Pro. La vista previa aparece al desbloquearlo.
Cuenta atrás con flip viene con Pro. La vista previa aparece al desbloquearlo.