Skip to content
Utilboxes

JSON Formatter

Pretty-print JSON with proper indentation, or minify it for production. Syntax errors are reported with the exact line and column.

Runs entirely in your browser

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.

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.