Home › Developer Tools › JSON Formatter

JSON Formatter

Paste JSON to beautify, minify or validate it. Errors are pinned to the exact line and column, and you can explore the data in a collapsible tree.

Input
Waiting for JSON…

      
      
Advertisement

How to use the JSON Formatter

  1. Paste your JSON into the left box, or upload a .json file.
  2. Check the status bar. Valid JSON shows a green tick. If there's a mistake, the line is highlighted and the message tells you what's wrong. Click Go to error to jump to it.
  3. Choose Beautify or Minify and the indentation you like. The result appears on the right.
  4. Switch to Tree view to fold and unfold objects and arrays. Click any key to see its path, such as $.users[0].email.
  5. Copy or download the formatted JSON.

Common JSON errors and how to fix them

ErrorWrongRight
Trailing comma{"a": 1, "b": 2,}{"a": 1, "b": 2}
Single quotes{'name': 'Ann'}{"name": "Ann"}
Unquoted key{name: "Ann"}{"name": "Ann"}
Missing comma["a" "b"]["a", "b"]
Comments{"a": 1 // note}{"a": 1, "note": "…"}
Python / JS valuesTrue, None, undefinedtrue, null
Line break in a string"line one
line two"
"line one\nline two"

Beautify vs. minify

Beautify (also called pretty print) puts each property on its own line and indents nested objects, which makes API responses and config files easy to read and compare. Minify removes all optional spaces and line breaks. Minified JSON is smaller, which is what you want for production config, requests and storage. Both keep your data exactly the same.

Frequently asked questions

What does a JSON formatter do?

It adds line breaks and indentation to JSON so it is easy to read (beautify), or removes all unnecessary whitespace to make it as small as possible (minify). It also checks that the JSON is valid.

Why is my JSON invalid?

The most common causes are a trailing comma after the last item, single quotes instead of double quotes, property names without quotes, comments, and missing commas between items. The validator shows the line, column and reason for the first error.

Is my JSON sent to a server?

No. Formatting and validation happen entirely in your browser, so private data such as API responses and config files never leave your device.

Will large numbers lose precision?

No. Beautify and Minify keep every number exactly as you wrote it, even very long IDs. Only the Sort keys option and the tree view read numbers as JavaScript numbers, which round beyond about 15 to 17 digits.

How big a file can I format?

Files of several megabytes work fine in a modern browser. Syntax colors are switched off for very large outputs to keep the page fast.

What is the difference between JSON and a JavaScript object?

JSON is stricter: keys must be in double quotes, strings must use double quotes, and trailing commas, comments, undefined and functions are not allowed.

Related tools