An interactive web application for visualizing JSON data as a hierarchical tree structure. Built with Next.js, TypeScript, React Flow, and Tailwind CSS.
π Live Demo: https://json-tree-visualizer-jet.vercel.app/
- JSON Input & Parsing: Text area with real-time validation and error messages
- Interactive Tree Visualization: Hierarchical tree using React Flow with smooth animations
- Node Type Differentiation: Color-coded nodes
- Blue: Objects
- Green: Arrays
- Orange: Primitive values (strings, numbers, booleans, null)
- Advanced Search: Search by JSON path (e.g.,
user.name,items[0].value) with highlighting and auto-pan - Zoom & Pan Controls: Built-in navigation controls with minimap
- Auto-fit View: Automatically fits all nodes to viewport when data is loaded
- Dark/Light Mode: Theme toggle with localStorage persistence
- Clear/Reset: Clear input and reset visualization
- Copy Path: Click nodes to copy their JSON path to clipboard
- Load Sample JSON: Quick start with sample data
- Download JSON: Export current JSON data as file
- Export Image: Export tree visualization as PNG image
- Node.js 18.0 or higher
- npm, yarn, pnpm, or bun
# Clone the repository
git clone <repository-url>
cd json-tree-visualizer
# Install dependencies
npm install
# Run development server
npm run dev
# Build for production
npm run build
# Start production server
npm startOpen http://localhost:3000 in your browser.
- Input JSON: Paste or type JSON in the left panel text area
- Visualize: Click the "Visualize" button to generate the interactive tree
- Search: Use the search bar to find nodes by path (e.g.,
user.name,items[0])- Matching nodes are highlighted
- View automatically pans to the first match
- Match count is displayed
- Navigate:
- Drag to pan the canvas
- Use zoom controls (in/out/fit view)
- Click nodes to select them
- View minimap for navigation overview
- Actions:
- Click "Sample" to load sample JSON
- Click nodes to copy their path
- Download current JSON data
- Export visualization as PNG image
- Toggle dark/light mode
- Clear all data
json-tree-visualizer/
βββ app/
β βββ layout.tsx # Root layout with theme provider
β βββ page.tsx # Main application page
β βββ globals.css # Global styles and Tailwind configuration
βββ components/
β βββ Button.tsx # Reusable button component
β βββ Controls.tsx # Control buttons (clear, copy, download, export)
β βββ CustomNode.tsx # Custom node rendering component
β βββ JSONInput.tsx # JSON input component with validation
β βββ SearchBar.tsx # Search functionality component
β βββ ThemeProvider.tsx # Dark/Light mode context provider
β βββ TreeVisualizer.tsx # React Flow tree visualization component
βββ hooks/
β βββ useImageExport.ts # Image export functionality
β βββ useJsonTree.ts # JSON parsing and tree building logic
β βββ useSearch.ts # Search functionality logic
β βββ useTreeVisualizer.ts # Tree state management and search matching
βββ layout/
β βββ Footer.tsx # Application footer
β βββ Header.tsx # Application header
β βββ MainContent.tsx # Main content layout
βββ types/
β βββ index.ts # TypeScript type definitions
βββ utils/
β βββ jsonParser.ts # JSON to tree conversion utilities
β βββ treeHelpers.ts # Tree helper functions
βββ public/ # Static assets
The application follows clean architecture principles with clear separation:
- Components: UI-only components with minimal logic
- Hooks: Business logic and state management
- Utils: Pure utility functions (parsing, helpers)
- Types: TypeScript type definitions
Manages JSON input, parsing, validation, and tree generation.
Handles search functionality with path matching and result highlighting.
Manages ReactFlow node and edge state, handles updates, initialization, and selection changes. Preserves node positions when possible.
Handles image export functionality with viewport capture and fallback mechanisms.
Reusable button component with multiple variants (primary, secondary, gradient, icon), sizes, loading states, and icon support.
Component for entering and validating JSON data with error display and action buttons.
Main visualization component using React Flow. Handles node rendering, search highlighting, and auto-fit view functionality.
Custom node rendering with type-specific colors, icons, and value display.
- Next.js 14: React framework with App Router
- TypeScript: Type-safe development
- React Flow: Interactive node-based graph visualization
- Tailwind CSS: Utility-first CSS framework
- Lucide React: Modern icon library
- html-to-image: Image export functionality
npm run dev # Start development server
npm run build # Build for production
npm run start # Start production server
npm run lint # Run ESLint- TypeScript for type safety
- ESLint for code quality
- Consistent formatting
- Component-based architecture
- Custom hooks for reusable logic
- JSDoc comments for documentation
The application is deployed on Vercel:
Live URL: https://json-tree-visualizer-jet.vercel.app/
- Push your code to GitHub
- Go to Vercel
- Click "Import Project"
- Select your GitHub repository
- Vercel will automatically detect Next.js
- Click "Deploy"
The application is configured for seamless Vercel deployment with optimized builds.
The application can be deployed to any platform that supports Next.js:
- Netlify: Connect GitHub repo, build command:
npm run build - AWS Amplify: Follow Next.js deployment guide
- GitHub Pages: Requires static export configuration
- Any Node.js hosting service: Configure to run
npm start
- JSON Input & Parsing with validation
- Tree Visualization using React Flow
- Node type differentiation (Objects/Arrays/Primitives)
- Search by JSON path
- Highlight matching nodes
- Auto-pan to matches
- Show match/no match messages
- Auto-fit view on initial load
- Dark/Light mode toggle
- Clear/Reset button
- Copy path feature
- Load sample data
- Download JSON
- Export image as PNG
- Zoom controls (built-in React Flow)
- Pan functionality (built-in React Flow)
- Minimap for navigation
- Chrome (latest)
- Firefox (latest)
- Safari (latest)
- Edge (latest)
- Optimized bundle size
- Efficient rendering with React memo
- Proper memoization with useCallback
- Smooth animations with CSS transitions
- Automatic view fitting for better UX
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
MIT License - feel free to use this project for learning and development.
Built with modern web technologies focusing on user experience, performance, and maintainability.
Made with β€οΈ using Next.js, React Flow, and Tailwind CSS
Live Demo: https://json-tree-visualizer-jet.vercel.app/