Skip to content

Repository files navigation

PrettyJSON

PrettyJSON Logo

Free Online JSON Formatter & Validator

Format, validate, and beautify your JSON with real-time syntax highlighting and professional features.

Next.js React Tailwind CSS shadcn/ui

Live Demo License


🚀 Live Demo

Try it now at prettyjson.vishkx.com


Preview

PrettyJSON Preview


✨ Features

Core Features

  • Real-time Formatting — Automatically formats and validates JSON as you type
  • Syntax Highlighting — Beautiful code highlighting powered by Monaco Editor
  • Pretty Print & Minify — Toggle between beautified and minified JSON output
  • JSON5 Support — Export to JSON5 format with comments and trailing commas
  • Customizable Indentation — Configure indent size (2, 4, or custom spaces)
  • Error Detection — Instant validation with clear error messages

Editor Features

  • Monaco Editor — VS Code's powerful editor with IntelliSense and auto-completion
  • Resizable Panels — Drag to resize editor and output panes on desktop
  • Dark/Light Mode — System-aware theme with animated toggle
  • Word Wrap Toggle — Enable/disable word wrapping in the editor
  • Fullscreen Mode — Expand the editor to fullscreen for focused editing
  • Skeleton Loaders — Professional loading states for smooth UX

Input Options

  • File Upload — Import JSON files directly via file picker
  • Drag & Drop — Drop JSON files onto the editor
  • Paste Example — Load sample JSON to explore features
  • Clear Input — One-click clear button

Output Options

  • Interactive Tree View — Collapsible/expandable JSON tree with search
  • Copy to Clipboard — Quickly copy formatted output
  • Download — Export as .json or .json5 files with custom filename
  • Share Links — Generate shareable URLs with expiring links (1 hour, 1 day, 1 week)
  • Customizable Display — Toggle data types, object sizes, font size, and more

Progressive Web App (PWA)

  • Installable — Add to home screen on mobile or desktop
  • Offline Support — Works without an internet connection
  • Responsive Design — Optimized for mobile, tablet, and desktop

📋 Roadmap / TODO

Quick Wins

  • Sort Keys — Alphabetically sort object keys for consistency
  • Escape/Unescape Strings — Handle escaped JSON strings
  • Keyboard Shortcuts Help — In-app modal showing all shortcuts (? key)
  • Sync Editor and Output Pane Themes — Ensure both panes follow the selected global theme
  • Responsive Dialogs — Improve UX by using popovers on desktop and drawers on mobile

Medium Priority

  • Fetch from URL — Import JSON directly from an API endpoint
  • JSON Repair — Auto-fix common errors (trailing commas, unquoted keys, single quotes)
  • Recent History — Store and access last 5 JSONs in localStorage
  • Flatten/Unflatten — Convert nested objects to flat key-value pairs

Larger Features

  • JSON Diff/Compare — Side-by-side comparison of two JSON objects
  • JSON Path Query — Filter JSON with JSONPath/JMESPath syntax
  • Convert to Other Formats — Export to YAML, CSV, TypeScript interfaces
  • JSON Schema Validation — Validate JSON against a schema
  • JWT Decoder — Decode and display JWT tokens
  • Multiple Tabs — Work with multiple JSON files simultaneously

UX Improvements

  • Onboarding Tour — Guide new users through features
  • Mobile Experience — Improve touch interactions and layout

🛠️ Tech Stack

Category Technology
Framework Next.js 16 (App Router, Server Components)
Language TypeScript
Styling Tailwind CSS 4
UI Library shadcn/ui
Code Editor Monaco Editor
JSON Tree View @uiw/react-json-view
State Management Zustand
URL State nuqs
Database Neon PostgreSQL + Drizzle ORM
Hosting Vercel

🏗️ Architecture

This project follows a server-first component architecture:

  • Server Components (default) — Layouts, pages, headers, footers, and static content
  • Client Components — Only where interactivity is required (editor, tree view, dialogs)

This maximizes performance by:

  • Reducing JavaScript bundle size
  • Enabling streaming SSR
  • Improving initial page load times

📦 Getting Started

Prerequisites

  • Node.js 20+ (or Bun)
  • A Neon PostgreSQL database (for share functionality)

Installation

  1. Clone the repository
git clone https://github.com/vishkx/prettyjson.git
cd prettyjson
  1. Install dependencies
bun install
# or
npm install
  1. Set up environment variables

Copy .env.example to .env and configure:

cp .env.example .env

Required environment variables:

# NeonDB Database Configuration
DATABASE_URL=postgresql://username:password@host.neon.tech/database?sslmode=require

# Cron Job Security (Optional - for Vercel deployment)
CRON_SECRET=your-random-secret-here
  1. Set up the database
bun run db:push
# or
npm run db:push
  1. Run the development server
bun dev
# or
npm run dev

Then open http://localhost:3000 in your browser.


📜 Available Scripts

Script Description
dev Start development server
build Create production build
start Start production server
lint Run ESLint
db:generate Generate Drizzle migrations
db:migrate Run database migrations
db:push Push schema changes to database
db:studio Open Drizzle Studio

📁 Project Structure

src/
├── app/
│   ├── (app)/                    # Main application routes
│   │   ├── (components)/         # Page-specific components
│   │   │   ├── editor-pane.tsx   # Monaco editor (client)
│   │   │   ├── output-pane.tsx   # JSON tree view (client)
│   │   │   ├── json-formatter.tsx # Main formatter logic (client)
│   │   │   ├── page-header.tsx   # Static header (server)
│   │   │   └── shared-json-loader.tsx # URL share loader (client)
│   │   ├── layout.tsx            # App layout (server)
│   │   ├── loading.tsx           # Loading skeleton (server)
│   │   └── page.tsx              # Main page (server)
│   ├── api/
│   │   ├── cron/                 # Scheduled cleanup jobs
│   │   └── share/                # Share link API endpoints
│   ├── layout.tsx                # Root layout with providers
│   ├── manifest.ts               # PWA manifest
│   ├── robots.ts                 # SEO robots.txt
│   └── sitemap.ts                # SEO sitemap
├── components/
│   ├── custom/                   # Custom components
│   │   ├── skeletons.tsx         # Skeleton loaders (server)
│   │   ├── animated-theme-toggler.tsx
│   │   ├── theme-color-toggle.tsx
│   │   └── ...
│   ├── dialogs/                  # Dialog components (share, download)
│   ├── layout/                   # Header & footer (server)
│   ├── seo/                      # SEO components
│   └── ui/                       # shadcn/ui components
├── db/
│   ├── index.ts                  # Database connection
│   └── schema.ts                 # Drizzle schema definitions
├── hooks/                        # Custom React hooks
├── lib/
│   ├── config.ts                 # Site configuration & SEO
│   ├── monaco.ts                 # Monaco editor setup
│   └── utils.ts                  # Utility functions
├── services/                     # API service functions
├── stores/                       # Zustand state stores
│   ├── settings-store.ts         # User preferences
│   └── share-store.ts            # Share functionality state
└── context/                      # React context providers

⌨️ Keyboard Shortcuts

Shortcut Action
Ctrl/Cmd + Enter Format JSON
Ctrl/Cmd + M Minify JSON

🌐 Deployment

Vercel (Recommended)

  1. Push your code to GitHub
  2. Import the repository in Vercel
  3. Add environment variables in Vercel dashboard
  4. Deploy!

Other Platforms

This is a standard Next.js application and can be deployed to any platform that supports Next.js:

  • Netlify
  • Railway
  • Docker / self-hosted

For platform-specific instructions, see the Next.js deployment docs.


🤝 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/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📄 License

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


👤 Author

Created and maintained by vishkx.


🙏 Acknowledgments


Made with ❤️ for the developer community

About

Free online JSON formatter & validator with real-time syntax highlighting, tree view, minify, prettify, and shareable links. Built with Next.js 16, React 19, Monaco Editor, and Tailwind CSS 4.

Topics

Resources

Code of conduct

Stars

3 stars

Watchers

0 watching

Forks

Contributors

Languages