JSON Formatter
Paste JSON or drop in a .json file, then press Format to indent it or Minify to strip whitespace. Invalid JSON is reported with the exact line and column and a caret under the problem — usually a trailing comma, single quotes or a comment. Parsing is strict (RFC 8259) and runs in your browser, so real data stays private.
Updated
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.
Tips and common mistakes
- Sort keys before comparing two versions of a document; otherwise the diff is full of reordering.
- Minify JSON for production payloads and keep the formatted version for reading and editing.
- Drop a .json file in directly instead of copying a large file into the clipboard.
- Use the line and column in an error message to jump straight to the problem in your editor.