✓ Valid JSON in green, or the error message in red. An orange note below it warns about valid JSON that changes when it is read, such as very large numbers or duplicate keys.Some things to know before you start:
42, "hi" and null all pass.JSON.parse rejects it, so the tool removes it first and tells you in a note.The tool does not write its own error messages. It shows the message from your browser's built-in JSON.parse. In Chrome and Edge, the message comes in one of two forms.
With a position. For example:
Expected double-quoted property name in JSON at position 16 (line 1 column 17)
Position counts characters from 0. Line and column count from 1. For long input, go to the line number and count across.
With a piece of your text. For example:
Unexpected token 'N', "{"a": NaN}" is not valid JSON
This form names the bad character and shows the text around it, but no position. Search your input for that text to find the spot.
Firefox and Safari word their messages differently. Firefox also gives a line and column. Safari's messages are shorter and may not say where the problem is. If you cannot find an error, try the same input in Chrome or Firefox.
One more thing: the reported spot is where the parser gave up. The real mistake is often just before it, on the same line or the line above.
Each example below shows the broken JSON, the fixed version, and the message Chrome gives for it.
A comma after the last item is fine in JavaScript, but not in JSON.
Broken: {"a": 1, "b": 2,}
Fixed: {"a": 1, "b": 2}
Message: Expected double-quoted property name ... (line 1 column 17). Column 17 is the } right after the extra comma. In an array, [1, 2, 3,] gives Unexpected token ']'.
Broken: {'name': 'Asha'}
Fixed: {"name": "Asha"}
Message: Expected property name or '}' in JSON at position 1. JSON strings and keys need double quotes. An apostrophe inside a string is fine: "it's".
Broken: {name: "Asha"}
Fixed: {"name": "Asha"}
You get the same message as for single quotes. Every key must be a string in double quotes.
Broken:
{
"a": 1 // note
}
Message: Expected ',' or '}' after property value ... (line 2 column 10). Column 10 is the first /. JSON has no comments of any kind. Delete them, or move the note into a normal key such as "_note".
Broken:
{
"a": 1
"b": 2
}
Message: Expected ',' or '}' after property value ... (line 3 column 3). The message points at "b" on line 3, but the comma is missing at the end of line 2. This is the most common case where the real mistake is one line above.
Broken: {"a": NaN, "b": undefined, "ok": True}
Fixed: {"a": null, "b": null, "ok": true}
Message: Unexpected token 'N'. JSON only has true, false and null, all in lower case. Use null for a missing value, or leave the key out.
Broken: {“name”: “Asha”}
Fixed: {"name": "Asha"}
Message: Expected property name or '}' in JSON at position 1. Word processors, chat apps and some websites change straight quotes into curly ones. They look almost the same. Retype the quotes, or use find and replace in a plain text editor.
A real line break inside a string gives Bad control character in string literal. Write \n instead. A Windows path such as "C:\path" gives Bad escaped character, because a single backslash starts an escape. Double it: "C:\\path".
Both buttons read your JSON with JSON.parse and write it again with JSON.stringify. So the output is rebuilt, not just re-spaced. For most JSON you will not notice. But these cases do change:
12345678901234567890 becomes 12345678901234567000. All three buttons show a note when the input has a whole number above that limit, with the first one and its line. If your data has long IDs, keep them as strings in quotes.1.50 becomes 1.5, 1e3 becomes 1000, and -0 becomes 0. A number too big to store, such as 1e400, becomes null.{"a": 1, "a": 2} only the last one is kept, so the output is {"a":2}. The input still counts as valid JSON, but all three buttons show a note with the first duplicate key and its line.{"b":1,"a":2,"2":3,"1":4} becomes {"1":4,"2":3,"b":1,"a":2}. Other keys keep their order. There is no option to sort keys.\u00e9 becomes é, and \/ becomes /. The value is the same, but the text is different.If you only want to check the JSON and keep the original text exactly as it is, use Validate.
Beautify when a person needs to read the JSON, for example to debug an API response or review a config change. Minify when a program reads it, for example a single-line environment variable, or when you want a smaller file. Minify only removes the spaces between values. Spaces inside strings stay. The changes listed in the section above happen with both buttons.
JSON looks like JavaScript, but it is much stricter. A JavaScript object can use single quotes, keys without quotes, trailing commas, comments, undefined and functions. JSON allows none of them. So an object copied from JavaScript code often fails here. If you have the object in a browser console, run JSON.stringify(yourObject, null, 2) there. It prints valid JSON, but it leaves out keys whose value is undefined or a function.
JavaScript stores numbers exactly only up to 9,007,199,254,740,991. Larger whole numbers are rounded when the tool reads them. For example, 12345678901234567890 becomes 12345678901234567000. The tool shows an orange note when it finds such a number. Store long IDs as strings so they stay exact.
No. Beautify always uses 2 spaces per level, and Minify puts everything on one line. If you need a different indent, copy the result into a code editor and change the indent setting there.
The message shows where the parser gave up, not where the mistake is. A missing comma at the end of line 2 is reported at the start of line 3. Look at the reported spot and the few characters just before it.
Yes, as a note. Duplicate keys are allowed by the browser's JSON parser, so the JSON still counts as valid. But the tool shows an orange note with the first duplicate key and its line. Beautify and Minify keep only the last value for each key.
No. The tool uses the JSON.parse and JSON.stringify functions built into your browser. The JSON you paste stays in the page and is not sent anywhere.