JSON Formatter
Pretty-print JSON with proper indentation, or minify it for production. Syntax errors are reported with the exact line and column.
How to use the JSON Formatter
- 1Paste your JSON, or drop in a .json file.
- 2Press Format to indent it, or Minify to strip whitespace.
- 3If the JSON is invalid, the error message points at the exact line and column.
- 4Copy the result or download it.
How it works
The text is parsed with the JavaScript engine's own JSON parser, which follows RFC 8259 strictly. That strictness is deliberate: it means anything this tool accepts will be accepted by every other conforming parser, so you are not lulled into shipping something that works here and fails in production.
Error reporting is where most formatters fall short. The native parser reports a character offset, which is useless in a 4,000-line file. That offset is translated into a line and column, and the offending line is shown with a caret under the problem — so you can see immediately that it was a trailing comma on line 812.
Sorting keys alphabetically is available as an option, which makes two versions of the same document diffable.
Everything runs in this page. Nothing you paste is transmitted, logged or stored, which is what makes it safe to drop a production payload in here while you are debugging.
Worked example
Finding an error in a large config file
- Paste 400 lines of JSON.
- The parser reports: Unexpected token } at line 218, column 3.
- The line is shown with a caret under the closing brace.
Result: A trailing comma on line 217 — found in seconds instead of by bisecting the file.