MultiConvers

How to Format JSON

Formatting JSON means parsing it, then reprinting the same value with consistent indentation. Invalid text cannot be formatted — fix the syntax first.

By Andreas Rosenberg

What “format” does

A formatter parses the text as JSON, then writes the same value back with line breaks and indentation. That is why a beautifier and a formatter are the same job. If parse fails, there is nothing safe to indent.

{"name":"Ada","ok":true}

becomes:

{
  "name": "Ada",
  "ok": true
}

Steps

  1. Paste the JSON. Do not wrap it in extra quotes unless those quotes are part of the document.
  2. Run Format (or Pretty-print). On MultiConvers you can pick 2- or 4-space indent.
  3. If you get a parse error, switch to validation and fix the line it points at.

The MultiConvers JSON formatter does this in the browser. The text is not uploaded.

What will not format

  • Trailing commas: {"a": 1,}
  • Comments: {"a": 1 /* no */}
  • Single quotes: {'a': 1}

Those belong to JSON5 or JavaScript, not JSON. Pretty-print is the same reprint step with a readability focus.

FAQ

Why did formatting fail on a trailing comma?

JSON does not allow a comma after the last property or array item. Remove it, then format again.

Will formatting change my data?

It should not change the value. Key order is preserved by typical engines. Whitespace and insignificant number spelling may be normalized.

Related guides

Related tools

See all guides.