Skip to content
Utilboxes

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.

Runs entirely in your browser

Updated

How to use the JSON Formatter

  1. 1Paste your JSON, or drop in a .json file.
  2. 2Press Format to indent it, or Minify to strip whitespace.
  3. 3If the JSON is invalid, the error message points at the exact line and column.
  4. 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

  1. Paste 400 lines of JSON.
  2. The parser reports: Unexpected token } at line 218, column 3.
  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.

Frequently asked questions

Why does my JSON say it is invalid?
The usual culprits are trailing commas, single quotes instead of double, unquoted keys, and comments. JSON allows none of these — the error message names the exact position.
Can JSON have comments?
No. The specification has no comment syntax. Formats like JSON5 and JSONC add them, but standard parsers reject them.
What indentation should I use?
Two spaces is the most common convention and keeps deeply nested documents readable. Four spaces and tabs are both supported.
Is my JSON sent to a server?
No. Parsing and formatting happen in your browser, which is why it is safe to paste real data here.
What is the difference between formatting and minifying?
Formatting adds line breaks and indentation for people to read. Minifying removes all unnecessary whitespace to make the data as small as possible. The data itself is identical.
Why did my keys change order?
Only if you turned on key sorting. Otherwise keys are kept in the order they were written.
Can I format a JSON file instead of pasted text?
Yes. Drop the .json file onto the input.

Guides