Json Viewer

A collapsible JSON tree for React with syntax coloured values, item counts on folded nodes, copy value and copy path buttons, search highlighting and arrow key navigation.

src/registry/ui/json-viewer.tsx/r/json-viewer.json

Installation#

bash
npx shadcn@latest add @minidev/json-viewer

MiniDev UI is in the shadcn registry directory, so the short form works with no setup. Older CLI versions can use the full URL: npx shadcn@latest add https://ui.minidev.pro/r/json-viewer.json

Usage#

tsx
import { JsonViewer } from "@/components/ui/json-viewer"

export function Example() {
  return (
    <JsonViewer value={{ name: "minidev-ui", items: 300 }} />
  )
}

API reference#

JsonViewer props
PropTypeDefault
valueunknownSAMPLE
titlestring"GET /v1/invoices/inv_8f3a2c"
rootNamestring""
defaultExpandDepthnumber1
defaultExpandedstring[]["$.customer", "$.lines", "$.lines[0]"]
toolbarbooleantrue
maxStringLengthnumber64
onCopy(text: string, kind: "value" | "path", path: string) => void-
aria-labelstring-
classNamestring-

Dependencies#

npm

lucide-react

Built from

No other MiniDev files

Examples#

All Developer tool UI components for React