A structured JSON viewer widget with a collapsible tree, syntax highlighting, copy-to-clipboard, and search. Designed for API response inspection, webhook payload debugging, and configuration review. Complements the existing CodeViewer (Monaco-based) with a lighter-weight, tree-oriented alternative.
Introduction
Overview
Developers and operators frequently need to inspect JSON data in SaaS dashboards, API explorers, and devtools panels. The existing CodeViewer uses Monaco Editor for full-featured code editing but is heavyweight for read-only JSON inspection. This widget provides a purpose-built, lightweight JSON tree viewer with collapse, search, and copy.
Goals
Parse and render JSON as a collapsible, syntax-highlighted tree.
Support expand/collapse at any node level, with expand-all/collapse-all controls.
Copy the full JSON or a subtree to the clipboard.
Search/filter within the JSON by key or value.
Ship Storybook stories with various JSON structures.
Non-Goals
JSON editing or mutation (use CodeViewer for editing).
A hierarchical representation of a JSON document with expandable nodes
Node
A key-value pair (object) or indexed element (array) in the tree
Syntax highlighting
Color-coding of data types (string, number, boolean, null)
Current State
code-viewer.tsx provides a Monaco Editor-based code viewer with syntax highlighting, section navigation, and copy/download. manifest-viewer.tsx re-exports CodeViewer. Both are full-featured but heavy (~hundreds of KB due to Monaco). No lightweight tree-based JSON viewer exists for simple inspection use cases.
Proposed Solution
Create a JsonViewer widget at src/components/widgets/json-viewer.tsx that:
Accepts a data prop (parsed object/array) or a raw string prop.
Renders a recursive tree of collapsible nodes.
Syntax-highlights keys, strings, numbers, booleans, and null values using design tokens.
Provides expand-all and collapse-all controls in a toolbar.
Supports copying the full JSON or any subtree via a context action.
Includes a search input that highlights matching keys and values and filters the tree.
Uses no external editor dependencies (pure React rendering).
Requirements
The viewer must handle JSON documents up to 1 MB without freezing the UI. Large arrays should virtualize or paginate. Invalid JSON input should show an error state, not crash.
Functional Requirements
ID
Requirement
Priority
FR-01
Parse and render a JSON object or array as a collapsible tree
Must
FR-02
Toggle expand/collapse on any node by clicking the node handle
Must
FR-03
Provide expand-all and collapse-all toolbar buttons