~ / developer / json-formatter

{ } JSON Formatter

Paste JSON, click once. Pretty print or minify — everything runs locally in your browser, nothing is uploaded.

input.json
output.json
waiting for input...

How to use the JSON formatter

  1. Paste your JSON into the input.json box on the left. Want to see how it works first? Click Sample to load example data.
  2. Click Format to get neatly indented JSON in the output.json box. You can also press Ctrl + Enter (⌘ + Enter on a Mac) inside the input box.
  3. Pick indent: 2, indent: 4 or indent: tab. The output re-formats as soon as you change it.
  4. Minify strips every space and line break and squeezes the JSON onto a single line.
  5. Use Copy output to copy the result and Clear to empty both boxes.

Pretty print vs. minify

Whitespace has no meaning in JSON, so adding or removing line breaks and indentation never changes the data itself. That's why the same payload is usually kept in two shapes depending on who is reading it:

InputFormat (indent 2)Minify
{ "a" : 1 , "b" : [true,null] }one key per line, array items on their own lines{"a":1,"b":[true,null]}
an 18 KB pretty-printed API responseunchanged structure, easy to readtypically 20–35% smaller

The character count of the result is shown under the output, so you can compare sizes before and after minifying.

How it works

The input is read with the browser's built-in JSON.parse and written back out with JSON.stringify. Nothing is sent to a server. If parsing succeeds you'll see ✓ valid JSON; if it fails you get ✗ plus the browser's own error message, so the formatter doubles as a quick syntax check. For an exact line-and-column error location with plain-English hints, use the JSON Validator.

Tips

Because the data is re-serialized, a few things can differ from the original: duplicate keys keep only the last value, numbers like 1.0 become 1, and very large integers (above 253 ≈ 9 quadrillion) lose precision. Comments, single quotes and trailing commas aren't standard JSON, so they're reported as errors.

FAQ

Does formatting change the order of keys?
No. Keys stay in the order they appear in the input. The one exception is integer-like keys such as "2" or "10": JavaScript object rules move them to the front in ascending numeric order.
Why do I get "Unexpected token" errors?
Almost always one of four things: single quotes instead of double quotes, an unquoted key, a trailing comma after the last item, or a comment. Check the text around the position mentioned in the error, or paste it into the JSON Validator for the exact line and column.
Is it safe to paste a company API response here?
Formatting happens entirely in your browser and nothing is uploaded or stored. Still, avoid pasting live tokens or passwords on a shared computer.
Should I use tabs or spaces for JSON?
There is no single right answer. JavaScript and web projects usually use 2 spaces, Python tooling often uses 4. Follow your team's .editorconfig or Prettier settings.
How do I minify JSON?
Paste it in and click Minify. All insignificant whitespace is removed and the result is a single line you can copy with Copy output.

Related tools