Skip to content

A professional, fast, and feature-rich JSON formatting tool built with vanilla JavaScript. Features real-time validation, syntax highlighting, tree view, file upload/download, and comprehensive JSON processing capabilities.

License

Notifications You must be signed in to change notification settings

koniz-dev/json-formatter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

11 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

JSON Formatter

JSON Formatter License GitHub Pages Version

A professional, fast, and feature-rich JSON formatting tool built with vanilla JavaScript

πŸš€ Live Demo β€’ πŸ“– Documentation β€’ πŸ› Report Bug β€’ πŸ’‘ Request Feature


πŸ“‹ Table of Contents


✨ Features

🎯 Core Functionality

  • πŸ”„ JSON Formatting - Convert minified JSON to beautifully formatted, readable code
  • πŸ” JSON Validation - Real-time syntax validation with detailed error reporting
  • πŸ“¦ JSON Minification - Compress JSON to reduce file size
  • 🎨 Syntax Highlighting - Color-coded JSON elements for better readability
  • πŸ”§ Auto-Fix Errors - Automatically correct common JSON syntax issues

πŸš€ Advanced Features

  • πŸ“‹ Clipboard Integration - One-click copy/paste functionality
  • πŸ’Ύ File Export - Download formatted JSON as .json files
  • πŸ“ File Upload - Upload and process JSON files directly
  • πŸ”— URL Loading - Load JSON data from remote URLs
  • 🌳 Tree View - Interactive hierarchical view of JSON structure
  • πŸ” Search & Filter - Find specific keys or values within JSON
  • πŸ“Š Statistics - View file size, depth, key count, and array statistics
  • βš™οΈ Customizable Options - Sort keys, multiple indent options, and JSON standards
  • ⌨️ Keyboard Shortcuts - Power user shortcuts for faster workflow
  • πŸ“± Responsive Design - Optimized for desktop, tablet, and mobile devices
  • πŸŒ™ Modern UI - Clean, professional interface with smooth animations

πŸ”§ Developer Features

  • 🚫 No Dependencies - Pure vanilla JavaScript, no frameworks required
  • ⚑ Fast Performance - Optimized for large JSON files
  • πŸ”’ Privacy-First - All processing happens client-side, no data sent to servers
  • β™Ώ Accessibility - WCAG compliant with keyboard navigation support
  • πŸ“ Multiple JSON Standards - Support for RFC 8259, RFC 7159, RFC 4627, and ECMA-404
  • 🎯 Flexible Indentation - 2, 3, 4 spaces or tab indentation options

πŸš€ Quick Start

Option 1: Use Online (Recommended)

Visit the live application: https://koniz-dev.github.io/json-formatter

Option 2: Run Locally

# Clone the repository
git clone https://github.com/koniz-dev/json-formatter.git
cd json-formatter

# Open in browser (no build process required)
open index.html
# or
python -m http.server 8000
# then visit http://localhost:8000

πŸ› οΈ Usage

Basic JSON Formatting

  1. Input: Paste, type, upload, or load JSON from URL
  2. Format: Click "Format JSON" or press Ctrl+Enter
  3. Output: View the formatted result with syntax highlighting

JSON Validation

  1. Input: Enter JSON to validate
  2. Validate: Click "Validate" button
  3. Result: See validation status with error details if invalid
  4. Auto-Fix: Enable auto-fix to automatically correct common errors

Input Methods

  • πŸ“ Manual Input: Type or paste JSON directly
  • πŸ“ File Upload: Click "Upload File" to select a .json file
  • πŸ”— URL Loading: Click "Load URL" to fetch JSON from a remote URL
  • πŸ’‘ Example: Click "Example" to load sample JSON data

Advanced Options

  • Sort Keys: Automatically alphabetize object keys
  • Indentation: Choose 2, 3, 4 spaces or tab indentation
  • JSON Standard: Select from RFC 8259, RFC 7159, RFC 4627, or ECMA-404
  • Auto-Fix Errors: Automatically correct common JSON syntax issues
  • Minify: Compress JSON to minimal size

View Options

  • 🌳 Tree View: Switch to interactive hierarchical view
  • πŸ” Search: Find specific keys or values within JSON
  • πŸ“Š Statistics: View file size, depth, key count, and array statistics

Export Options

  • Copy: Copy formatted JSON to clipboard
  • Download: Save as .json file

⌨️ Keyboard Shortcuts

Shortcut Action Description
Ctrl+Enter Format JSON Format the current input
Ctrl+K Clear All Clear input and output
Ctrl+Shift+C Copy Result Copy output to clipboard
Ctrl+V Paste Paste from clipboard (when input focused)
Ctrl+U Upload File Open file upload dialog
Ctrl+L Load URL Open URL loading modal
Ctrl+F Search Focus search input
Ctrl+T Tree View Toggle tree view mode
Ctrl+E Example Load example JSON
Escape Close Modal Close any open modal

πŸ—οΈ Architecture

json-formatter/
β”œβ”€β”€ πŸ“„ index.html          # Main application structure
β”œβ”€β”€ 🎨 styles.css          # Responsive styling and animations
β”œβ”€β”€ ⚑ script.js           # Core application logic
β”œβ”€β”€ πŸ“– README.md           # Project documentation
β”œβ”€β”€ πŸ“„ LICENSE             # MIT License
β”œβ”€β”€ 🚫 .gitignore          # Git ignore rules
└── πŸ–ΌοΈ favicon/            # Favicon assets
    β”œβ”€β”€ favicon.ico
    β”œβ”€β”€ favicon-16x16.png
    β”œβ”€β”€ favicon-32x32.png
    β”œβ”€β”€ apple-touch-icon.png
    └── site.webmanifest

Key Components

  • JSONFormatter Class: Main application controller with comprehensive functionality
  • Syntax Highlighter: Custom JSON syntax highlighting engine
  • Error Handler: Comprehensive error reporting system with auto-fix capabilities
  • Clipboard Manager: Cross-browser clipboard integration
  • File Exporter: Client-side file download functionality
  • URL Loader: Remote JSON fetching with CORS handling
  • File Upload Handler: Local file processing and validation
  • Tree View Renderer: Interactive hierarchical JSON visualization
  • Search Engine: Real-time JSON content search and filtering
  • Statistics Calculator: JSON structure analysis and metrics
  • Modal Manager: User interface modal handling
  • Toast Notification System: User feedback and status messages

πŸš€ Deployment

GitHub Pages (Current)

This project is automatically deployed to GitHub Pages:

  1. Repository: koniz-dev/json-formatter
  2. Live URL: https://koniz-dev.github.io/json-formatter
  3. Auto-deploy: Updates automatically on every push to main branch

Custom Deployment

Deploy to any static hosting service:

# Build (no build process needed - just copy files)
cp -r . /path/to/web/server/

# Or use with any static site generator
# Files are ready for Netlify, Vercel, AWS S3, etc.

πŸ› οΈ Technologies

Core Technologies

  • HTML5 - Semantic markup and modern web standards
  • CSS3 - Advanced styling with Flexbox, Grid, and animations
  • Vanilla JavaScript (ES6+) - Modern JavaScript without frameworks
  • Web APIs - Clipboard API, File API, Blob API, and Fetch API

External Resources

  • Google Fonts - Inter font family for typography
  • Font Awesome 6.0 - Professional icon set via CDN
  • CSS Gradients - Modern visual design
  • Web App Manifest - PWA capabilities

Performance Optimizations

  • Debounced Input - Optimized real-time validation and search
  • Efficient Parsing - Fast JSON processing with error recovery
  • Minimal DOM Manipulation - Smooth user experience
  • Event Delegation - Optimized event handling
  • Lazy Loading - Resources loaded on demand
  • Memory Management - Efficient tree view rendering
  • Caching - Smart caching for URL-loaded content

Browser APIs Used

  • Clipboard API - Copy/paste functionality
  • File API - File upload and processing
  • Blob API - File download generation
  • Fetch API - Remote JSON loading
  • URL API - URL validation and processing
  • History API - Browser history management

πŸ“± Browser Support

Browser Version Support
Chrome 60+ βœ… Full Support
Firefox 55+ βœ… Full Support
Safari 12+ βœ… Full Support
Edge 79+ βœ… Full Support
IE 11+ ⚠️ Limited Support

Feature Support

  • Clipboard API: Modern browsers only (Chrome 66+, Firefox 63+, Safari 13.1+)
  • File Download: All supported browsers
  • File Upload: All supported browsers
  • URL Loading: All supported browsers (with CORS support)
  • JSON Parsing: Universal support
  • Tree View: All supported browsers
  • Search & Filter: All supported browsers
  • Statistics: All supported browsers

🀝 Contributing

We welcome contributions! Here's how you can help:

πŸ› Bug Reports

  1. Check existing issues
  2. Create a new issue with detailed description
  3. Include browser version and steps to reproduce

πŸ’‘ Feature Requests

  1. Open an issue
  2. Describe the feature and its benefits
  3. Use the "enhancement" label

πŸ”§ Code Contributions

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes
  4. Test thoroughly
  5. Commit: git commit -m 'Add amazing feature'
  6. Push: git push origin feature/amazing-feature
  7. Open a Pull Request

πŸ“‹ Development Guidelines

  • Follow existing code style
  • Add comments for complex logic
  • Test on multiple browsers
  • Ensure responsive design
  • Update documentation if needed

πŸ“„ License

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


⭐ If you found this project helpful, please give it a star!

⬆ Back to Top

About

A professional, fast, and feature-rich JSON formatting tool built with vanilla JavaScript. Features real-time validation, syntax highlighting, tree view, file upload/download, and comprehensive JSON processing capabilities.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published