Developer

JSON formatter

Format with two-space indents, or minify to one line. Invalid JSON stops with the line number instead of a cleaned-up guess.

Validation runs in this browser. The JSON is not uploaded.

How it works

Format parses the text and writes it back with two spaces of indent. Minify parses it and writes it back with no extra space. Both paths use the same parser, so a file that formats will also minify.

If the text is not JSON, the page reports the parser message and the line. The line comes from a small scan that stops at the first value it cannot accept, which covers engines that do not include a character position. The text stays in your browser.

Formula

  • Format
    parse, then stringify with two spaces
  • Minify
    parse, then stringify with no space

Worked examples

A compact object

{ "a": 1 } formats as a brace, an indented "a": 1, and a closing brace. Minify turns it back into {"a":1}.

A broken second line

An object whose second line is "a": } is invalid. The message points at line 2, where the value should have been.

What the buttons do
ButtonValid JSONInvalid JSON
FormatTwo-space indentError and line
MinifyOne lineError and line
EitherSame parseNo guessed repair

Common questions

Is the JSON uploaded?

No. Parsing and formatting run in your browser.

Will it fix trailing commas?

No. Trailing commas are not JSON. The page reports the error instead of silently removing them.

Does key order change?

The parser keeps the order of the keys in the text you pasted. Format and minify write that same order back.

Why a line and not a column?

The line is the reliable piece across browsers. The parser message is shown next to it when the engine includes more detail.