By Mian Shafiq · Published · Updated
Paste your JSON into the JSON Formatter and press Beautify. If it's valid, you get it back indented and color-coded. If it isn't, you get an error message that's accurate but often confusing: a trailing comma, for example, makes Chrome say it "expected a double-quoted property name". Below are the real messages for the mistakes we see most, what each one is actually pointing at, and how to fix it.
Everything runs in your browser. The JSON isn't sent to our server, so it's fine to paste API responses that contain tokens or customer data.
Here's what beautified output looks like:
{
"name": "Ali",
"tags": [
"a",
"b"
]
}
The formatter shows your browser's own parser message after "Error: Invalid JSON". We ran common mistakes through the same JSON parser Chrome and Edge use and copied the exact wording. Firefox and Safari phrase their messages differently, but they point at the same spot.
| What you pasted | Message you'll see | What's really wrong |
|---|---|---|
{"a": 1, "b": 2,} | Expected double-quoted property name | A trailing comma after the last item. The parser saw the comma and waited for another key. |
{"name": "Ali" "age": 30} | Expected ',' or '}' after property value | A missing comma between two items. |
{"a": [1, 2, 3] | Expected ',' or '}' after property value | An unclosed brace. Same message as a missing comma; see the tip below. |
[1, 2 | Expected ',' or ']' after array element | An unclosed square bracket, usually from copying only part of a response. |
{'name': 'Ali'} | Expected property name or '}' | Single quotes. JSON only accepts double quotes. |
{name: "Ali"} | Expected property name or '}' | A key without quotes. Fine in JavaScript, not in JSON. |
{“name”: “Ali”} | Expected property name or '}' | Curly "smart" quotes, which Word, Google Docs and some chat apps add automatically. |
{"a": 1 // note} | Expected ',' or '}' after property value | A comment. JSON doesn't allow comments of any kind. |
{"a": "hel | Unterminated string | A string with no closing quote. |
| A string with a real line break inside | Bad control character in string literal | Line breaks and tabs inside a string must be written as \n and \t. |
{"ok": True} or None | Unexpected token 'T' (or 'N') | Python output. JSON uses lowercase true, false and null. |
{"n": 007} | Unexpected number | A number with a leading zero. Write 7, or "007" if it's really a code. |
{"a":1}{"b":2} | Unexpected non-whitespace character after JSON | Two JSON values pasted together, common with log files that hold one object per line. |
Chrome and Edge end the message with a position, such as at position 15 (line 1 column 16). The line and column point to the character where the parser gave up. Two habits make that useful:
Minified JSON from an API is all on line 1, so the column number can be in the thousands. Your code editor's "go to column" feature, or a search for the text near that point, gets you there faster than scrolling.
Only in whitespace. The keys, values and structure are identical, and any program reads both the same way. Beautified JSON is for people reading it; minified JSON is smaller to send and store. The formatter does change one thing worth knowing: if the same key appears twice in an object, only the last value is kept, because that's how JSON parsers in browsers work.
A validator answers "is this valid JSON?" A formatter makes valid JSON readable. Ours does both in one step: it parses the JSON first, shows the error if there is one, and only formats it when parsing succeeds. It doesn't check your data against a schema, so it won't tell you that a required field is missing, only that the syntax is right.
%22 and %7B.JavaScript object syntax is looser. It allows single quotes, unquoted keys, trailing commas and comments. JSON allows none of them, so code that runs fine as a JavaScript object can fail as JSON.
No. It tells you where the problem is, and you make the fix. That's deliberate: guessing whether a stray quote was meant to end a string can silently change your data.
With this one, the JSON never leaves your browser. As a general rule, though, check that a formatter works locally before pasting secrets, and rotate any key you've pasted somewhere you're unsure about.
There's no set limit, since it runs on your own device rather than our server. The practical limit is your browser: very large files can make the page sluggish while it colors the output.