JSON Formatter
Format and validate JSON with error location and line/column details
Usage Instructions
🚀 Quick Start
- Enter/Paste: type or paste JSON into the input area
- Real-time validation: checks syntax as you type; errors show below with line/column
- Format: click ‘Format’ to pretty-print and replace the input with the result
- Minify: click ‘Minify’ to remove whitespace/newlines; replaces the input
- Copy: click the copy button below to copy the current content
📌 Common Scenarios
- API debugging: quickly validate backend JSON and improve readability
- Log inspection: format JSON snippets from logs to locate issues
- Configuration: review structure, unify key order and indentation style
- Code review: include clear JSON examples in PRs/docs
- Pre-commit check: normalize JSON format/indentation before committing
🎛️ Formatting Parameters & Actions
- Indent size: use the dropdown next to the buttons to choose Tab/2/4/8
- Sort: click ‘Sort’ to alphabetically sort object keys (semantics unchanged); copy/submit uses current content
🧭 Usage Advice
- Escapes: use valid escapes in strings (e.g., " and \ +)
- Consistency: agree on indentation, key order, and schema within the team
- Backup before sorting: sorting changes key order and cannot be auto-reverted; copy a backup first
- Use ‘Line X, Column Y’ below the input and inspect around it
- Minify then format to surface extra commas or mismatched quotes
⚠️ Limitations & Compatibility
- No comments: // and /* */ are not standard JSON (use JSON5/JSONC tools)
- No single quotes: 'text' is not a valid JSON string
- No trailing commas: {"a":1,} or [1,] is invalid
- Large JSON: to keep the page responsive, consider splitting; very deep/huge structures may be simplified
🔒 Privacy & Security
- All processing happens in your browser; data never leaves your device
❓ FAQ
Why do single quotes/comments/trailing commas/NaN cause errors?
These are non-standard JSON (or JS extensions): strings must use double quotes; comments are not allowed; trailing commas are invalid; NaN/Infinity are unsupported.
How do I quickly locate the error?
Use the line/column info (e.g., line 10, column 5), then inspect surrounding quotes and brackets.
How to get the smallest JSON for transport?
Use ‘Minify’ to remove all whitespace and newlines; prefer minified JSON for production transfer.