ADVERTISEMENT · Top banner
Your Google AdSense unit renders here once you set your publisher ID.

How to Fix Common JSON Syntax Errors

JSON is strict, and a single stray character breaks the whole file. The good news: almost every error falls into a handful of categories. Here's how to recognize and fix each.

1. Trailing commas

JSON does not allow a comma after the last item:

{ "a": 1, "b": 2, }   ← invalid (comma after 2)
{ "a": 1, "b": 2 }    ← valid

This is the most common error, especially after deleting a line. Remove the final comma in any object or array.

2. Single quotes instead of double

JSON keys and string values must use double quotes. {'a': 1} is invalid; it must be {"a": 1}. Single quotes are valid in JavaScript but not in JSON.

3. Unquoted keys

Every key needs quotes: {name: "Sam"} is invalid; use {"name": "Sam"}. (This trips up people coming from JavaScript object literals.)

4. Missing or mismatched brackets

Every { needs a } and every [ a ]. A missing closing bracket usually shows as an error at the very end of the file. Pretty-printing helps you see the nesting and spot the gap.

5. Wrong value types

6. Unescaped characters in strings

Inside a string, a literal double quote or backslash must be escaped: "He said \"hi\"". Newlines inside strings must be \n, not actual line breaks.

Find the error fast

Paste your JSON into our JSON formatter — it validates instantly and points to the line and column of the problem, so you don't have to hunt. Everything runs in your browser, so even sensitive data stays private.

FAQ

Can JSON have comments?

No. If you need comments (e.g. config files), use JSON5 or JSONC, but standard JSON parsers will reject them.

Why does my error say "unexpected token"?

The parser hit a character it didn't expect — often a trailing comma, single quote, or missing bracket at that position.

Open the JSON Formatter →

ADVERTISEMENT · In-content
Your Google AdSense unit renders here once you set your publisher ID.

More free tools

Word Counter
Count words, characters, sentences & reading time — instantly, privately.
Image Compressor
Compress JPG, PNG, WebP & GIF in your browser. No limits, no uploads.
PDF Tools
Merge, split, rotate & reorder PDFs. Unlimited, free, no watermark.
QR Code Generator
Free QR codes that NEVER expire and don't track your scans.
Password Generator
Strong, random passwords generated locally. Never sent anywhere.
Unit Converter
Convert length, weight, temperature, data, speed & more — instantly.
ADVERTISEMENT · Footer
Your Google AdSense unit renders here once you set your publisher ID.