Skip to content

aduquehd/json-formatter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎨 JSON Viewer

A modern web application for viewing and formatting JSON data with a VS Code-style editor interface

Live Demo

Next.js React TypeScript Tailwind CSS pnpm


✨ Features

  • πŸ“ Monaco Editor: VS Code-style code editor with syntax highlighting, line numbers, and minimap
  • 🎯 JSON Formatting: Paste raw or encoded JSON and format it with proper indentation
  • 🌳 Tree View: Interactive tree view with expand/collapse functionality and inline editing
  • βœ… Real-time Validation: Live JSON validation with error highlighting
  • πŸ“ Code Folding: Collapse and expand JSON sections
  • 🎨 Theme Support: Light and dark themes with automatic editor theme switching
  • πŸ” Search & Replace: Built-in search functionality with regex support
  • πŸ“‹ Copy to Clipboard: One-click copy of formatted JSON
  • πŸ“± Modern UI: Clean, responsive design that works on all devices
  • πŸ”€ JSON Diff View: Compare two JSON objects side-by-side with highlighted differences
  • 🏷️ JavaScript Object Literal Support: Parse and format JavaScript object literal syntax
  • πŸ“Š Graph View: Visualize JSON structure as an interactive network graph with D3.js
  • πŸ“ˆ Chart View: Visual representation of data distribution with Chart.js
  • πŸ—ΊοΈ Map View: Display geographical data on an interactive Leaflet map
  • πŸ“Š Statistics View: Detailed analysis of JSON data types and structure
  • πŸ”§ JSON Auto-fix: Automatic correction of common JSON errors
  • πŸ”’ 100% Local Processing: All data processing happens in your browserβ€”no data is ever sent to any server

πŸ“‹ Requirements

  • πŸ“¦ Node.js 18.x or later
  • πŸš€ pnpm (recommended) or npm

πŸš€ Quick Start

  1. Clone the repository:

    git clone <repository-url>
    cd json-viewer
  2. Install dependencies using pnpm (recommended):

    pnpm install

    Or using npm:

    npm install
  3. Set up environment variables (optional):

    cp .env.example .env.local

    Edit .env.local and add your analytics ID if you want tracking:

    # Google Analytics (optional)
    NEXT_PUBLIC_GA_MEASUREMENT_ID=G-XXXXXXXXXX
    
  4. Run the development server:

    pnpm dev
    # or
    npm run dev
  5. Open your browser and go to http://localhost:3000

πŸ’» Development

πŸ› οΈ Available Scripts

# Start development server with hot-reload
pnpm dev

# Build for production
pnpm build

# Start production server
pnpm start

# Run linting
pnpm lint

🎨 Code Quality

The project uses ESLint for code quality and consistency:

# Check for linting issues
pnpm lint

# Auto-fix linting issues (when possible)
pnpm lint --fix

πŸ—οΈ Production Build

Build the application for production:

pnpm build

This will create an optimized production build with:

  • πŸ“¦ Optimized bundle sizes
  • πŸš€ Code splitting
  • πŸ–ΌοΈ Image optimization
  • ⚑ Static asset caching

Start the production server:

pnpm start

The production server will run on http://localhost:3000

πŸ“‚ Project Structure

json-viewer/
β”œβ”€β”€ πŸ“ src/
β”‚   β”œβ”€β”€ πŸ“ app/                    # Next.js App Router
β”‚   β”‚   β”œβ”€β”€ 🎨 globals.css         # Global styles and CSS variables
β”‚   β”‚   β”œβ”€β”€ πŸ“„ layout.tsx          # Root layout with metadata
β”‚   β”‚   └── πŸ“„ page.tsx            # Main application page
β”‚   β”œβ”€β”€ πŸ“ components/             # React components
β”‚   β”‚   β”œβ”€β”€ πŸ“ EditorView.tsx      # Monaco Editor integration
β”‚   β”‚   β”œβ”€β”€ 🌳 TreeView.tsx        # Interactive JSON tree
β”‚   β”‚   β”œβ”€β”€ πŸ“Š GraphView.tsx       # D3.js network visualization
β”‚   β”‚   β”œβ”€β”€ πŸ“ˆ ChartView.tsx       # Chart.js data visualization
β”‚   β”‚   β”œβ”€β”€ πŸ—ΊοΈ MapView.tsx         # Leaflet geographic visualization
β”‚   β”‚   β”œβ”€β”€ πŸ”€ DiffView.tsx        # JSON comparison tool
β”‚   β”‚   β”œβ”€β”€ πŸ“Š StatsView.tsx       # JSON statistics analysis
β”‚   β”‚   β”œβ”€β”€ πŸ” SearchView.tsx      # Advanced search functionality
β”‚   β”‚   β”œβ”€β”€ πŸŽ›οΈ ControlButtons.tsx  # Format/Compact/Copy controls
β”‚   β”‚   β”œβ”€β”€ πŸ“‘ TabsContainer.tsx   # Tab navigation system
β”‚   β”‚   β”œβ”€β”€ 🎯 Navbar.tsx          # Navigation bar
β”‚   β”‚   β”œβ”€β”€ πŸŒ“ ThemeProvider.tsx   # Theme management
β”‚   β”‚   └── πŸ“š JsonExampleModal.tsx # Example JSON selector
β”‚   β”œβ”€β”€ πŸ“ hooks/                  # Custom React hooks
β”‚   β”‚   β”œβ”€β”€ 🎨 useTheme.ts         # Theme management hook
β”‚   β”‚   └── πŸ”” useNotification.ts  # Notification system hook
β”‚   └── πŸ“ utils/                  # Utility functions
β”‚       β”œβ”€β”€ πŸ”§ jsonFixer.ts        # JSON auto-correction
β”‚       β”œβ”€β”€ πŸ“¦ jsonUtils.ts        # JSON formatting utilities
β”‚       └── πŸ“ exampleData.ts      # Sample JSON data
β”œβ”€β”€ πŸ“ public/                     # Static assets
β”‚   └── πŸ“ img/                    # Images and icons
β”œβ”€β”€ πŸ“¦ package.json                # Dependencies and scripts
β”œβ”€β”€ βš™οΈ tsconfig.json               # TypeScript configuration
β”œβ”€β”€ 🎨 tailwind.config.js          # Tailwind CSS configuration
β”œβ”€β”€ πŸ“„ postcss.config.js           # PostCSS configuration
β”œβ”€β”€ πŸš€ next.config.js              # Next.js configuration

πŸ› οΈ Technology Stack

Frontend Framework

Next.js React TypeScript

Styling

Tailwind CSS CSS3

Editor & Visualizations

Monaco Editor D3.js Chart.js Leaflet

Development Tools

pnpm ESLint Vercel

πŸš€ Key Features Explained

Monaco Editor Integration

Professional-grade code editor with VS Code features including:

  • Syntax highlighting for JSON
  • Auto-completion and IntelliSense
  • Multiple cursors and selection
  • Find and replace with regex support
  • Code folding and minimap

Interactive Visualizations

  • Tree View: Navigate complex JSON structures with collapsible nodes
  • Graph View: Network visualization using D3.js force-directed graphs
  • Chart View: Automatic data type detection and chart generation
  • Map View: GeoJSON support with interactive Leaflet maps

Smart JSON Processing

  • Automatic error detection and correction
  • Support for JavaScript object literal syntax
  • JSON minification and beautification
  • Deep object comparison with diff highlighting

πŸ”§ Configuration

Environment Variables

Variable Description Required Default
NEXT_PUBLIC_GA_MEASUREMENT_ID Google Analytics Measurement ID (format: G-XXXXXXXXXX) No -

If the analytics ID is not provided, the tracking script will not be loaded, ensuring complete privacy for users who prefer not to use tracking.

Theme Customization

Themes are configured in src/app/globals.css using CSS custom properties. The application supports automatic theme switching based on system preferences.

Editor Settings

Monaco Editor can be customized in src/components/EditorView.tsx:

  • Font size and family
  • Tab size and indentation
  • Word wrap and line numbers
  • Minimap and scrollbar behavior

πŸ“¦ Deployment

Vercel (Recommended)

Deploy to Vercel with one click:

Deploy with Vercel

Manual Deployment

  1. Build the application:

    pnpm build
  2. The build output will be in .next/ directory

  3. Deploy using your preferred hosting service that supports Next.js

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


Made with ❀️ by aduquehd

🌐 Live Demo β€’ πŸ› Report Bug β€’ πŸš€ Request Feature

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •