An interactive web application that transforms raw JSON data into an intuitive hierarchical tree structure, allowing users to explore, search, and interact with data visually β in real time.
https://json-visualizer-mu.vercel.app/
- Overview
- Features
- Tech Stack
- Architecture
- Getting Started
- How It Works
- Component Structure
- React Flow Implementation
- Usage Guide
- Future Enhancements
- License
JSON Tree Visualizer is a browser-based tool that helps developers, data scientists, and analysts understand and debug complex JSON structures with ease. It automatically parses and validates JSON, then renders a node-based tree graph using React Flow β where each key, value, and nested object becomes an interactive visual node.
- Real-time JSON Validation β Instantly detect syntax errors and receive friendly error messages.
- Interactive Tree Rendering β Explore your JSON through a clear, node-based tree layout powered by React Flow.
- JSONPath Search β Quickly locate nodes using JSONPath-like queries with instant highlighting.
- Dark/Light Mode β Seamless theme toggle for all-day coding comfort.
- Copy Node Path β Click any node to copy its JSON path to clipboard.
- Zoom & Pan Controls β Effortlessly navigate even the largest data structures.
- Objects β Blue/Indigo gradient
- Arrays β Green/Emerald gradient
- Primitives β Orange/Amber gradient (for strings, numbers, booleans, null)
- Search Highlights β Bright yellow glow + scale animation
- React 19.1.1 β Component-based UI framework
- Vite 7.1.7 β Fast development server and bundler
- React Flow 11.11.4 β Interactive graph visualization library
- Tailwind CSS 3.4.1 β Utility-first styling framework
- PostCSS & Autoprefixer β CSS transformations and cross-browser compatibility
- Lucide React 0.548.0 β Modern, clean icon library
- Input Stage β User pastes or types JSON.
- Validation Stage β JSON.parse() ensures correct syntax.
- Transformation Stage β Tree builder recursively constructs nodes and edges.
- Rendering Stage β React Flow renders a visual graph.
- Interaction Stage β Search, zoom, pan, and node interactions are handled dynamically.
- Node.js v16+
- npm or yarn
# Clone repository
git clone <repository-url>
cd json-tree-visualizer
# Install dependencies
npm install
# Start development server
npm run dev
# Build production version
npm run build
# Preview production build
npm run previewServer runs at http://localhost:5173 by default.
Validates user input before visualization:
try {
const data = JSON.parse(jsonInput);
} catch (err) {
setError('Invalid JSON: ' + err.message);
}The buildTree function recursively processes JSON:
- Identify node type (object, array, primitive)
- Assign unique IDs
- Establish parent-child connections
- Position nodes hierarchically
- Y-axis β Depth Level
- X-axis β Child Distribution
- Parent Centered above children
Each edge links parent and child:
{
id: 'edge-parent-child',
source: 'parent-id',
target: 'child-id',
type: 'smoothstep',
markerEnd: { type: MarkerType.ArrowClosed }
}src/
βββ components/
β βββ CustomNode.jsx
β βββ JsonInput.jsx
β βββ SearchPanel.jsx
β βββ TreeView.jsx
β βββ JsonTreeVisualizer.jsx
βββ utils/
β βββ treeBuilder.js
βββ App.jsx
βββ main.jsx
- CustomNode.jsx β Node rendering, type-based styling, and interaction handling
- JsonInput.jsx β JSON input + validation controls
- SearchPanel.jsx β Search interface and logic
- TreeView.jsx β React Flow setup and event handling
- JsonTreeVisualizer.jsx β Core orchestrator, state manager
- Custom node types via
useMemo - Edge definitions with smooth transitions
- Built-in controls for zoom and view management
- Highlighted node animation during search
- Input JSON β Paste or write your JSON.
- Visualize β Click View to render.
- Navigate β Scroll to zoom, drag to pan.
- Search β Type JSONPath (e.g.,
$.user.name). - Interact β Click nodes to copy path.
- Toggle Theme β Use the light/dark switch.
$.user.name β userβs name
$.items[0].price β price of first item
$.address.city β nested object property
- Objects
{ } - Arrays
[ ] - Strings
"text" - Numbers
42 - Booleans
true / false - Null
null - Nested combinations
- Handles up to ~1000 nodes smoothly
- Deeply nested (>20 levels) JSONs may impact render speed
- Search optimized using in-memory data indexing
- Export tree as PNG/SVG
- Collapsible node groups
- Node filtering by type
- In-tree JSON editing
- Schema validation
- JSON comparison mode
- React Flow for visualization backbone
- Tailwind CSS for sleek styling
- Lucide React for icons
