JSON Formatter and Validator

Paste JSON to format, validate, minify, sort keys or repair common mistakes such as trailing commas. It runs in your browser.

Lines: 1
Output will appear here
Lines: 1

How to use the JSON formatter

  1. Paste JSON into the left editor, or upload a .json file.
  2. Press Format to indent it (choose 2, 3 or 4 spaces), or Minify to put it on one line.
  3. If it is invalid, the error message tells you what is wrong and where. Try Repair for common mistakes, then check the result.
  4. Use Sort to order keys alphabetically, Tree to browse nested data, and Copy or Download to take the result away.

Everything runs in your browser. Nothing you type is sent to our servers. Your last input is remembered in this browser so it is still there if you reload; clear the editor to remove it.

The mistakes that make JSON invalid

JSON is stricter than JavaScript. Most errors come from writing it the way you would write a JavaScript object or a Python dictionary. The Repair button fixes the first five in this table. It reads the text character by character, so it never changes anything inside a string, such as a URL or an apostrophe.

InvalidValidRule
{'name': 'Ada'}{"name": "Ada"}Strings and keys need double quotes
{name: "Ada"}{"name": "Ada"}Keys must be quoted
[1, 2, 3,][1, 2, 3]No trailing commas
{"a": 1 // note}{"a": 1}No comments
{"ok": True}{"ok": true}true, false and null are lower case
{"n": NaN}{"n": null}NaN and Infinity are not allowed

Large numbers lose precision

Formatting works by parsing the JSON and writing it out again. JavaScript stores every number as a 64-bit float, so integers larger than 9,007,199,254,740,991 (2 to the power 53, minus 1) cannot be held exactly: 12345678901234567890 comes back as 12345678901234567000. If your JSON has long IDs, such as Twitter or database snowflake IDs, keep them as strings, or check them after formatting.

When you would use it

  • Making an API response or log entry readable before you debug it.
  • Finding the exact line and character that is breaking a config file.
  • Minifying JSON to paste into an environment variable or a single-line field.
  • Sorting keys so that two JSON documents can be compared with a text diff.

Frequently asked questions

Why does it say my JSON is invalid when it works in JavaScript?

JavaScript object literals allow single quotes, unquoted keys, trailing commas and comments. JSON allows none of these. Press Repair to fix them, or use the table above to find the problem.

Does formatting change my data?

It changes whitespace only, with one exception: integers above 2 to the power 53 lose precision, because JavaScript cannot represent them exactly. Sort also changes the order of keys, which JSON treats as insignificant.

How large a file can it handle?

Several megabytes works in a modern browser. Very large files can make the page slow, because the whole document is parsed and displayed at once; a command line tool such as jq is better for those.

What is the difference between Format and Minify?

Format adds line breaks and indentation for reading. Minify removes all unnecessary whitespace for the smallest size. Both produce the same data.

Related tools and guides

Related Articles

Learn more about JSON Tools with our expert guides.

View all posts

This tool runs in your browser. What you enter is processed on your device and is not sent to our servers.

Building something bigger?

We design and build web and mobile applications and the APIs behind them.