How to fix common JSON errors

You paste a response into your code, call JSON.parse(), and get “Unexpected token”. JSON is strict: one stray comma or the wrong kind of quote makes the whole document invalid. The good news is that almost every JSON error comes from the same ten mistakes, and the error message tells you exactly where to look — once you know how to read it.

Step 1: read the error message properly

Every parser reports where it gave up. The wording differs by language, but the information is the same:

WhereTypical message
Chrome / Node.jsExpected double-quoted property name in JSON at position 7 (line 1 column 8)
FirefoxJSON.parse: expected property name or '}' at line 1 column 8
PythonJSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 8 (char 7)

The position counts characters from the start of the text (starting at 0); the line and column are easier for humans. The real mistake is usually at or just before that spot — the parser only notices a problem when the next character doesn’t fit.

Tip: paste your JSON into the JSON Formatter and press Validate. It shows the line and column and moves your cursor straight to the problem.

Step 2: check the ten usual suspects

1. Trailing commas

JavaScript allows a comma after the last item; JSON does not.

{ "name": "Rahim", "age": 28, }   ✗
{ "name": "Rahim", "age": 28 }    ✓

2. Single quotes

Strings and keys must use double quotes ". 'Dhaka' is invalid.

3. Keys without quotes

{ name: "Rahim" } is a valid JavaScript object but invalid JSON. Every key needs double quotes: { "name": "Rahim" }.

4. Comments

JSON has no comments — neither // … nor /* … */. If you need notes in a config file, use a field such as "_comment", or a format that supports comments (JSONC, YAML).

5. A missing comma between items

{ "city": "Dhaka" "zip": "1216" }   ✗  (comma missing after "Dhaka")

6. Mismatched brackets

Every { needs a } and every [ needs a ], in the right order. “Unexpected end of JSON input” almost always means something was never closed — often because the text was cut off (a truncated log line or a half-copied response).

7. Unescaped characters inside strings

A double quote inside a string must be written \", a backslash as \\, and a real line break as \n. Windows paths are a classic trap: "C:\Users\rahim" is invalid; write "C:\\Users\\rahim".

8. JavaScript values that JSON doesn’t have

undefined, NaN, Infinity, functions and dates are not JSON. Use null for missing values and ISO strings such as "2026-09-27T10:00:00Z" for dates.

9. Python’s True, False and None

If you copied a Python print() of a dict, you’ll see True, False, None and single quotes. JSON needs true, false, null and double quotes. In Python, use json.dumps(data) instead of print(data).

10. Invisible characters

“Smart” quotes (“ ”) from Word or chat apps, a byte-order mark at the start of a file, or a non-breaking space can all break parsing while looking perfectly normal. If the error points at a character you can’t see, retype the quotes around that spot.

Fix most of these in one click. The JSON Formatter’s “Fix errors” button repairs comments, trailing commas, single quotes, unquoted keys and Python’s True/False/None. Try it now

Step 3: prevent it next time

FAQ

What does “Unexpected token < in JSON at position 0” mean?

The text you parsed starts with < — it is HTML, not JSON. Usually the server returned an error page (404, 500) or a login page. Check the URL and the HTTP status code.

Are duplicate keys an error?

Most parsers accept them and silently keep the last value, which hides bugs. The JSON standard says keys should be unique, so treat duplicates as a mistake.

Is my data safe in the online formatter?

Yes. JSON Bondhu processes everything in your browser; nothing you paste is uploaded.

JSON-এর সাধারণ ভুল কীভাবে ঠিক করবেন

কোনো রেসপন্স কোডে বসালেন, JSON.parse() চালালেন, আর পেলেন “Unexpected token”। JSON খুব কড়া নিয়মের: একটা বাড়তি কমা বা ভুল ধরনের কোট থাকলেই পুরো ডকুমেন্ট অবৈধ হয়ে যায়। ভালো খবর হলো, প্রায় সব JSON এরর আসে একই দশটি ভুল থেকে, আর এরর মেসেজ ঠিক কোথায় দেখতে হবে তা বলে দেয় — শুধু পড়তে জানতে হয়।

ধাপ ১: এরর মেসেজ ঠিকমতো পড়ুন

প্রতিটি পার্সার জানায় সে কোথায় থেমে গেছে। ভাষাভেদে লেখা আলাদা, কিন্তু তথ্য একই:

কোথায়সাধারণ মেসেজ
Chrome / Node.jsExpected double-quoted property name in JSON at position 7 (line 1 column 8)
FirefoxJSON.parse: expected property name or '}' at line 1 column 8
PythonJSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 8 (char 7)

position হলো লেখার শুরু থেকে কততম অক্ষর (০ থেকে গোনা); line ও column মানুষের পক্ষে বোঝা সহজ। আসল ভুলটা সাধারণত ঠিক ওই জায়গায় বা তার একটু আগে থাকে — কারণ পরের অক্ষরটা না মেলা পর্যন্ত পার্সার সমস্যা টের পায় না।

টিপ: আপনার JSON JSON ফরম্যাটারে পেস্ট করে যাচাই চাপুন। এটি লাইন ও কলাম দেখায় এবং কার্সর সরাসরি সমস্যার জায়গায় নিয়ে যায়।

ধাপ ২: দশটি পরিচিত সন্দেহভাজন দেখুন

১. শেষের বাড়তি কমা

JavaScript শেষ আইটেমের পরে কমা মেনে নেয়; JSON নেয় না।

{ "name": "Rahim", "age": 28, }   ✗
{ "name": "Rahim", "age": 28 }    ✓

২. সিঙ্গেল কোট

স্ট্রিং ও কী-তে অবশ্যই ডাবল কোট " লাগবে। 'Dhaka' অবৈধ।

৩. কোট ছাড়া কী

{ name: "Rahim" } বৈধ JavaScript অবজেক্ট, কিন্তু অবৈধ JSON। প্রতিটি কী-তে ডাবল কোট দরকার: { "name": "Rahim" }।

৪. কমেন্ট

JSON-এ কোনো কমেন্ট নেই — // … বা /* … */ কোনোটিই না। কনফিগ ফাইলে নোট রাখতে চাইলে "_comment"-এর মতো একটি ফিল্ড ব্যবহার করুন, অথবা কমেন্ট সমর্থন করে এমন ফরম্যাট (JSONC, YAML)।

৫. দুই আইটেমের মাঝে কমা নেই

{ "city": "Dhaka" "zip": "1216" }   ✗  ("Dhaka"-এর পরে কমা নেই)

৬. ব্র্যাকেট না মেলা

প্রতিটি {-এর জন্য একটি } আর প্রতিটি [-এর জন্য একটি ] লাগবে, সঠিক ক্রমে। “Unexpected end of JSON input” প্রায় সবসময় মানে কিছু একটা বন্ধ হয়নি — প্রায়ই কারণ লেখাটা মাঝপথে কেটে গেছে (লগের কাটা লাইন বা অর্ধেক কপি করা রেসপন্স)।

৭. স্ট্রিংয়ের ভেতরে এসকেপ না করা অক্ষর

স্ট্রিংয়ের ভেতরে ডাবল কোট লিখতে হয় \", ব্যাকস্ল্যাশ \\, আর আসল লাইন-ব্রেক \n দিয়ে। Windows-এর পাথ একটি পরিচিত ফাঁদ: "C:\Users\rahim" অবৈধ; লিখুন "C:\\Users\\rahim"।

৮. JavaScript-এর এমন মান যা JSON-এ নেই

undefined, NaN, Infinity, ফাংশন ও তারিখ JSON নয়। অনুপস্থিত মানের জন্য null আর তারিখের জন্য "2026-09-27T10:00:00Z"-এর মতো ISO স্ট্রিং ব্যবহার করুন।

৯. Python-এর True, False ও None

Python-এ dict print() করে কপি করলে দেখবেন True, False, None আর সিঙ্গেল কোট। JSON-এ লাগে true, false, null ও ডাবল কোট। Python-এ print(data)-এর বদলে json.dumps(data) ব্যবহার করুন।

১০. অদৃশ্য অক্ষর

Word বা চ্যাট অ্যাপ থেকে আসা “স্মার্ট” কোট (“ ”), ফাইলের শুরুতে byte-order mark, বা non-breaking space — দেখতে একদম স্বাভাবিক হলেও পার্সিং ভেঙে দিতে পারে। এরর যদি এমন অক্ষর দেখায় যা চোখে পড়ে না, ওই জায়গার কোটগুলো নতুন করে টাইপ করুন।

বেশিরভাগ ভুল এক ক্লিকে ঠিক করুন। JSON ফরম্যাটারের “ভুল ঠিক করুন” বোতাম কমেন্ট, শেষের কমা, সিঙ্গেল কোট, কোট ছাড়া কী আর Python-এর True/False/None ঠিক করে দেয়। এখনই চেষ্টা করুন

ধাপ ৩: পরের বার যেন না হয়

প্রশ্নোত্তর

“Unexpected token < in JSON at position 0” মানে কী?

আপনি যে লেখা পার্স করেছেন তা < দিয়ে শুরু — অর্থাৎ এটি HTML, JSON নয়। সাধারণত সার্ভার একটি এরর পেজ (404, 500) বা লগইন পেজ ফেরত দিয়েছে। URL আর HTTP স্ট্যাটাস কোড দেখুন।

একই কী দুবার থাকলে কি ভুল?

বেশিরভাগ পার্সার মেনে নেয় এবং চুপচাপ শেষের মানটি রাখে, ফলে বাগ লুকিয়ে যায়। JSON স্ট্যান্ডার্ড বলে কী-গুলো অনন্য হওয়া উচিত, তাই দুবার থাকাকে ভুল হিসেবেই ধরুন।

অনলাইন ফরম্যাটারে আমার ডেটা কি নিরাপদ?

হ্যাঁ। JSON বন্ধু সব কিছু আপনার ব্রাউজারেই প্রসেস করে; যা পেস্ট করেন তা কোথাও আপলোড হয় না।

Related guides

More free tools