FileToolsHub logo

JSON Formatter

JSON Formatter pretty-prints valid JSON with two-space indentation and keeps key order. Trailing commas, comments, and single quotes make it fail.

Key order stays b, then a. The indent is two spaces.
{"b":1,"a":[2,3]}
{
  "b": 1,
  "a": [
    2,
    3
  ]
}

Processing: runs in your browser, nothing uploaded

✓ Free to use✓ No sign-up needed✓ Nothing to install

About JSON Formatter

A minified API payload is one long line. JSON Formatter parses it and prints it with two-space indentation so you can read it.

Pretty print, not a repair

The tool runs JSON.parse, then JSON.stringify with an indent of 2. Key order stays as the parser returned it. There is no “sort keys” switch, no tabs-versus-spaces switch, and no minify button on this screen. A trailing comma, a comment, or a single-quoted string fails the parse. The error is the engine’s message, not a line-by-line linter. JSON Validator only tells you the text parses. JSON Diff compares two documents. XML to JSON is a different input. /blog/json-formatter-vs-validator separates the two jobs. Two spaces is the only indent this screen offers.

package.json and arrays

A package.json file is ordinary JSON. Paste it and you get the same two-space layout. This does not install packages, resolve versions, or warn about a missing script. A JSON array formats the same way as an object. Very large pastes can make the tab slow because the work is local. Strip secrets before you screenshot the result. The text never uploads. Indentation does not change the data. A parser that accepted the minified line will accept the pretty copy.

When the formatter should refuse

If the text is JSON5, a JavaScript object, or a log line with a sentence in front of the brace, fix the input. The formatter will not delete the sentence for you. It will not convert CSV. It will not pretty-print XML. JSON Viewer is for collapsing a tree. After a successful format, copy the output. The original paste is still in the input box until you replace it. Copy from the output box, not from a screenshot. A line that wraps on screen is still one JSON string.

How to use

  1. 1

    Paste valid JSON. Trailing commas and comments will fail.

  2. 2

    Run the formatter. Indentation is two spaces.

  3. 3

    Copy the result. The text stays in the browser.

Privacy

JSON Formatter parses the paste in this browser and does not upload the text.

Frequently asked questions

How many spaces does the JSON formatter use?

Two. There is no tab option and no minify button on this tool. Key order stays as the parser returned it.

Why did my JSON fail to format?

JSON.parse rejected it. Trailing commas, comments, and single quotes are invalid JSON. Fix those, then format again.

Can it format a package.json file?

Yes, if the file is valid JSON. It does not install packages or check scripts. An array formats the same way as an object.

Does formatting upload my JSON?

No. Parse and print run in the browser. JSON Validator only checks that the text parses. The pretty copy is still the same data.

Browse all Text Tools · Sitemap