Command Palette

Search for a command to run...

Dev Tools/JSON Viewer

JSON Viewer

Collapsible JSON tree viewer with syntax highlighting, search, and copy path

Open in v0Open in
{
name:"John Doe"
age:30
email:"john@example.com"
address:{
street:"123 Main St"
city:"San Francisco"
country:"USA"
}
hobbies:[
0:"coding"
1:"reading"
2:"gaming"
]
active:true
}

Overview

A collapsible JSON tree viewer with syntax highlighting, search functionality, and copy-path support. Perfect for inspecting API responses, configuration objects, or any JSON data.

Installation

bunx shadcn@latest add @elements/json-viewer

Usage

import { JsonViewer } from "@/components/elements/devtools/json-viewer";

const data = {
  user: {
    id: 1,
    name: "John Doe",
    email: "john@example.com",
    roles: ["admin", "user"]
  }
};

export function DataInspector() {
  return (
    <JsonViewer
      data={data}
      searchable
      copyPath
      collapsed={2}
    />
  );
}

Props

PropTypeDefaultDescription
dataJsonValue-JSON data to display
collapsedboolean | numberfalseInitial collapse state or depth level
searchablebooleanfalseEnable search filtering
copyPathbooleantrueShow copy path button on hover
maxDepthnumber10Maximum depth to render
classNamestring-Additional CSS classes

Features

  • Collapsible tree nodes
  • Syntax highlighting for different types
  • Search/filter functionality
  • Copy JSON path on click
  • Configurable collapse depth
  • Type-colored values (strings, numbers, booleans, null)