JSON Formatter

Paste JSON to check it, tidy it or shrink it.

How to use this tool

  1. Paste your JSON into the box. It is checked as you type.
  2. Choose Format to indent it, or Minify to remove all spaces.
  3. If it is invalid, the message gives the line and column to fix.

How it works

The page parses your text with the browser's own JSON parser. If parsing works, the data is written back out with your chosen indentation. If it fails, the parser's message is shown with the position converted into a line and column.

Common causes of errors are trailing commas, single quotes instead of double quotes, unquoted keys and comments, none of which JSON allows.

Example. {"a":1,"b":[1,2]} becomes a readable block with each key on its own line. Minify turns it back into one line.

Common JSON errors

Most failures come from habits carried over from JavaScript or other formats:

  • A trailing comma after the last item.
  • Single quotes around keys or strings. JSON needs double quotes.
  • Keys without quotes, such as {name: "Ada"}.
  • Comments. JSON does not allow // or /* */.
  • A missing comma between two items.
  • A raw line break inside a string. Write it as \n instead.

Frequently asked questions

What is the difference between JSON and a JavaScript object?

JSON is a text format with stricter rules. Keys must be in double quotes, and values cannot be functions, undefined or comments.

Why did my numbers change after formatting?

Integers beyond 9,007,199,254,740,991 lose precision in JavaScript and may be rounded. Keep those as strings.

Is my JSON sent to a server?

No. Everything runs in your browser, so API keys, tokens and customer data in pasted JSON stay on your device.

Why does my JSON fail with a trailing comma?

The JSON standard does not allow a comma after the last item in an object or array. Remove it and the check will pass.

Does sorting keys change my data?

It reorders object keys alphabetically, including nested ones. Array order is kept. The values are not changed.

Can it handle large files?

It handles several megabytes on most devices. Very large files may slow down a phone.

Need a website or web tool built?

We build websites, web tools and mobile apps.

Start a Project