Format, validate or minify JSON

Format, check or minify JSON. Runs on your device.

How it works

  1. Paste JSON or load a file
  2. Choose format, minify or check
  3. Copy or download

What the checker accepts

The checker follows RFC 8259, the standard definition of JSON. Strings and object keys use double quotes. Comments are not allowed, and neither is a comma after the last item. Any single value can stand alone at the top level, so 42, "hi" and null are valid JSON on their own, and so are objects and lists. The page reports the first problem it finds, with the line and column, and says in plain words what is wrong. It does not repair anything. A text with single quotes, unquoted keys, a trailing comma or a comment is reported as an error, even when JavaScript or a looser format such as JSON5 would accept it. The same goes for a bare word such as undefined or NaN. Only true, false and null can be written without quotes.

Reading the error

An error reads like Invalid JSON at line 3, column 14, followed by a reason. Under it the page shows the line that holds the problem and a caret (^) under the character where the checker stopped. Take a text whose third line is a list ending in 2 and a comma before the closing bracket: the checker stops at that bracket, line 3, column 14. Columns count characters, not bytes, so an emoji counts as one, and a tab counts as one too. The caret line replaces each tab with one space so the caret stays under the right character. A very long line is cut to a window of 80 characters around the problem. Press Show in the text to put the cursor on that character in the box above. The checker stops at the first error, so fix it and the next one, if there is one, appears.

What formatting changes and what it leaves alone

Formatting changes only spaces and line breaks. Every number, string and name is copied exactly as you wrote it, and so are the order of keys and any repeated keys. Many formatters parse the text and print it again, which rewrites the data: 12345678901234567890 would come out as 12345678901234567000, and 1.0 as 1, because JavaScript numbers cannot hold every digit. This page does not parse the numbers at all, so 12345678901234567890, 1.0 and 1E3 stay as they are, and an escape such as \u00e9 is not turned into the letter. Minify does the opposite of Format: it removes every space and line break between the parts, and nothing else. The data is the same before and after. It does not compress the text, it does not hide it, and it does not sort keys or remove repeated ones.

Limits and your data

You can paste or type up to 2,097,152 characters, or load one UTF-8 text file of up to 2 MB. The file does not need to end in .json; it is judged by its content. Indented output is built only when it would be 10,000,000 characters or fewer. A deeply nested text can be small and still become huge when indented, because every level adds spaces to every line below it. When that happens the page says so and suggests Minify or Check only. The box shows the first 100,000 characters of a long output, and Copy and Download give all of it. Nothing is uploaded and the text is not stored: close the tab and it is gone. The page counts visits with Google Analytics, using only the name of the tool and the fact that a result appeared, and no text is in those counts.

Frequently asked questions

Why is a trailing comma an error when JavaScript allows it?

JSON is a stricter format than JavaScript. A comma after the last item, as in [1,2,], is valid in a JavaScript list but not in JSON, so most programs that read JSON reject it. The checker reports it as an error at the closing bracket and tells you to remove the comma.

Does it change big numbers?

No. A number is copied as written, so 12345678901234567890 stays 12345678901234567890 and 1.0 stays 1.0. A formatter that parses and prints the data would show 12345678901234567000 and 1, because it has to turn the digits into a JavaScript number first.

Can it sort keys or remove duplicates?

No. Keys stay in the order you wrote them, and a repeated key such as {"a":1,"a":2} keeps both members. The text counts as valid, and the Keys tile counts the repeated name twice.

Does it read JSON with comments or JSON5?

No. A // or /* comment is reported as an error at the line and column where it starts, and so are single quotes and unquoted keys. Remove the comment or convert the file to plain JSON first. The page never edits your text for you.

What is the size limit?

You can paste up to 2,097,152 characters or load a file of up to 2 MB. Indented output over 10,000,000 characters is not built, which can happen with a deeply nested list of 1,000 levels. Minify and Check only still work then.

Is my JSON uploaded or saved?

No. The text is read and checked in this tab. It is not sent anywhere, put in the page address or stored; the only things the page remembers are the Output and Indent choices. A file you load is read on your device and its name is not shown or kept.