JSON Formatter

Formats JSON with 2- or 4-space indentation or minifies it to a single line, and shows the parser error when the input is not valid JSON.

Loading…

How to use

  1. Paste or type JSON into the input box. The result updates as you type.
  2. Under Indent, choose 2 spaces or 4 spaces for readable output, or Minify to remove all whitespace and put everything on one line.
  3. If the input is not valid JSON, the parser error is shown instead of the result. Fix the input and the result appears again.
  4. Press Copy to copy the formatted result to the clipboard.

Frequently asked questions

Is my JSON sent to a server?
No. Formatting is done in your browser with its built-in JSON parser.
Why does it say my JSON is invalid?
The input must be strict JSON. The most common causes are a trailing comma after the last item, single quotes instead of double quotes, keys without quotes, and comments (// or /* */). Values such as undefined, NaN or Infinity are also not allowed.
Where exactly is the error?
The message comes from your browser’s JSON parser, so its wording differs between browsers. Most browsers include the position, or the line and column, where parsing stopped; the actual mistake is usually at or just before that point.
Does formatting change my data?
The output is rebuilt from the parsed data, so it can differ from the original. If a key appears twice in the same object, only the last value is kept; keys that are whole numbers (such as "1" or "2") move to the front in ascending order; and escapes such as \u00e9 become the actual character (é). See the next question for how numbers can change.
Why did a long number change?
Numbers are read as JavaScript double-precision values, so integers larger than 9007199254740991 and decimals with many digits may change, 1.0 is written as 1 and 1E2 as 100, and numbers out of range such as 1e400 become null. Store long IDs as strings if every digit matters.