Skip to content

An interactive web application that transforms JSON data into a hierarchical tree structure with real-time search and highlighting capabilities.

Notifications You must be signed in to change notification settings

Adyasha56/JSON_Visualizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

JSON Tree Visualizer

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.

πŸ”— Live Demo

https://json-visualizer-mu.vercel.app/


πŸ“˜ Table of Contents


🧩 Overview

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.


βš™οΈ Features

πŸ” Core Functionality

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

🎨 Visual Differentiation

  • Objects β†’ Blue/Indigo gradient
  • Arrays β†’ Green/Emerald gradient
  • Primitives β†’ Orange/Amber gradient (for strings, numbers, booleans, null)
  • Search Highlights β†’ Bright yellow glow + scale animation

πŸ› οΈ Tech Stack

Frontend

  • React 19.1.1 – Component-based UI framework
  • Vite 7.1.7 – Fast development server and bundler

Visualization

  • React Flow 11.11.4 – Interactive graph visualization library

Styling

  • Tailwind CSS 3.4.1 – Utility-first styling framework
  • PostCSS & Autoprefixer – CSS transformations and cross-browser compatibility

Icons

  • Lucide React 0.548.0 – Modern, clean icon library

🧠 Architecture

Application Flow

JSON Visualization Process

Data Flow

  1. Input Stage – User pastes or types JSON.
  2. Validation Stage – JSON.parse() ensures correct syntax.
  3. Transformation Stage – Tree builder recursively constructs nodes and edges.
  4. Rendering Stage – React Flow renders a visual graph.
  5. Interaction Stage – Search, zoom, pan, and node interactions are handled dynamically.

πŸš€ Getting Started

Prerequisites

  • Node.js v16+
  • npm or yarn

Installation

# 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 preview

Server runs at http://localhost:5173 by default.


🧩 How It Works

1. JSON Parsing & Validation

Validates user input before visualization:

try {
  const data = JSON.parse(jsonInput);
} catch (err) {
  setError('Invalid JSON: ' + err.message);
}

2. Tree Construction Algorithm

The buildTree function recursively processes JSON:

  • Identify node type (object, array, primitive)
  • Assign unique IDs
  • Establish parent-child connections
  • Position nodes hierarchically

3. Layout Strategy

- Y-axis β†’ Depth Level
- X-axis β†’ Child Distribution
- Parent Centered above children

4. Edge Creation

Each edge links parent and child:

{
  id: 'edge-parent-child',
  source: 'parent-id',
  target: 'child-id',
  type: 'smoothstep',
  markerEnd: { type: MarkerType.ArrowClosed }
}

🧱 Component Structure

src/
β”œβ”€β”€ components/
β”‚   β”œβ”€β”€ CustomNode.jsx
β”‚   β”œβ”€β”€ JsonInput.jsx
β”‚   β”œβ”€β”€ SearchPanel.jsx
β”‚   β”œβ”€β”€ TreeView.jsx
β”‚   └── JsonTreeVisualizer.jsx
β”œβ”€β”€ utils/
β”‚   └── treeBuilder.js
β”œβ”€β”€ App.jsx
└── main.jsx

Responsibilities

  • 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

🌐 React Flow Implementation

  • Custom node types via useMemo
  • Edge definitions with smooth transitions
  • Built-in controls for zoom and view management
  • Highlighted node animation during search

🧭 Usage Guide

  1. Input JSON β†’ Paste or write your JSON.
  2. Visualize β†’ Click View to render.
  3. Navigate β†’ Scroll to zoom, drag to pan.
  4. Search β†’ Type JSONPath (e.g., $.user.name).
  5. Interact β†’ Click nodes to copy path.
  6. Toggle Theme β†’ Use the light/dark switch.

Example JSONPath Queries

$.user.name           β†’ user’s name  
$.items[0].price      β†’ price of first item  
$.address.city        β†’ nested object property  

🧩 Supported Data Types

  • Objects { }
  • Arrays [ ]
  • Strings "text"
  • Numbers 42
  • Booleans true / false
  • Null null
  • Nested combinations

⚑ Performance Notes

  • Handles up to ~1000 nodes smoothly
  • Deeply nested (>20 levels) JSONs may impact render speed
  • Search optimized using in-memory data indexing

🌱 Future Enhancements

  • Export tree as PNG/SVG
  • Collapsible node groups
  • Node filtering by type
  • In-tree JSON editing
  • Schema validation
  • JSON comparison mode

πŸ™Œ Acknowledgments

  • React Flow for visualization backbone
  • Tailwind CSS for sleek styling
  • Lucide React for icons

About

An interactive web application that transforms JSON data into a hierarchical tree structure with real-time search and highlighting capabilities.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published