Developer Tools

JSON Formatter Guide: What Each JSON Error Actually Means

By · 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.

How do I format JSON online?

  1. Open the JSON Formatter and paste your JSON into the input box (on the left on a computer, on top on a phone).
  2. Press Beautify. Valid JSON comes back with four-space indentation, with keys, strings, numbers and true/false/null in different colors.
  3. Press Minify to squash it back onto one line, for a config value or an API request.
  4. Press Copy to put the result on your clipboard.

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"
    ]
}

What does each JSON error message mean?

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 pastedMessage you'll seeWhat's really wrong
{"a": 1, "b": 2,}Expected double-quoted property nameA trailing comma after the last item. The parser saw the comma and waited for another key.
{"name": "Ali" "age": 30}Expected ',' or '}' after property valueA missing comma between two items.
{"a": [1, 2, 3]Expected ',' or '}' after property valueAn unclosed brace. Same message as a missing comma; see the tip below.
[1, 2Expected ',' or ']' after array elementAn 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 valueA comment. JSON doesn't allow comments of any kind.
{"a": "helUnterminated stringA string with no closing quote.
A string with a real line break insideBad control character in string literalLine breaks and tabs inside a string must be written as \n and \t.
{"ok": True} or NoneUnexpected token 'T' (or 'N')Python output. JSON uses lowercase true, false and null.
{"n": 007}Unexpected numberA number with a leading zero. Write 7, or "007" if it's really a code.
{"a":1}{"b":2}Unexpected non-whitespace character after JSONTwo JSON values pasted together, common with log files that hold one object per line.

How do I find where the error is?

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:

  • Look just before the spot, not at it. The parser fails at the first character that can't fit, which is usually right after the real mistake. For a missing comma, the column points at the start of the next key.
  • Check whether it points at the very end. A missing comma and an unclosed brace give the same message. If the column is the last character of your input, something was opened and never closed. If it's in the middle, look for a missing comma.

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.

Is formatted JSON different from minified JSON?

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.

What's the difference between a JSON formatter and a validator?

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.

Which related tools help with JSON?

  • CSV to JSON turns a spreadsheet export into a JSON array, one object per row.
  • Base64 Encode/Decode lets you read the JSON hidden in the middle part of a JWT token.
  • URL Encode/Decode helps when JSON has been squeezed into a query string and arrives full of %22 and %7B.

Questions people ask

Why does my JSON work in JavaScript but fail here?

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.

Can the formatter fix my JSON automatically?

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.

Is it safe to paste API keys into an online JSON formatter?

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.

How big a JSON file can I format?

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.