✳ DEVELOPER · JSON DEBUGGING
Common JSON Parse Errors and How to Fix Them
Fix invalid JSON from trailing commas, single quotes, missing brackets and escaped characters with tested examples.
Try JSON Formatter & Validator ↗Start by separating syntax from data problems
A JSON parser tells you whether the input follows JSON syntax. It does not know whether an id field is valid, whether a price is reasonable, or whether a required field is missing according to your application. Use a formatter or validator to locate syntax problems first, then apply schema or business-rule checks separately.
1. Trailing commas
This object is invalid: {"active":true,}. The comma after the final value is not allowed in JSON, even though some JavaScript object literal styles accept it. Remove the comma so it reads {"active":true}. The Vyblet JSON Formatter can validate syntax and then pretty-print the result.
2. Single quotes and unquoted keys
JSON requires double quotation marks around property names and string values. {'name':'Ada'} and {name:"Ada"} are not valid JSON. Write {"name":"Ada"}. If you are copying an object from JavaScript source code, convert it to valid JSON rather than assuming the syntax is identical.
3. Unmatched brackets and wrong nesting
Arrays use square brackets [] while objects use curly braces {}. The input {"tags":["red","blue"} is invalid because its array is closed with a curly brace instead of a square bracket. For a nested response, indentation often makes a missing closing bracket easier to identify, once the syntax errors have been corrected.
4. Unescaped quotation marks and special characters
Inside a JSON string, a literal quotation mark must be escaped. Write {"message":"She said \"hello\""}, not an unescaped pair of quotes. Similarly, line breaks within a JSON string need escape sequences such as \n rather than raw line-break characters. Pay attention to the source language: a backslash in a JavaScript string often needs another level of escaping.
5. Valid JSON can still hold surprises
Consider {"id":1,"id":2}. Many JSON parsers accept duplicate keys and keep the last one, creating a logic issue despite valid syntax. Similarly, very large integers may be rounded by JavaScript's Number type. Formatting or validating JSON does not solve duplicate-key policies, integer precision or schema compliance.
Repeatable fix-and-test checklist
- Paste a small, non-sensitive example into the formatter.
- Choose Validate and read the parse error.
- Correct the original content: quotes, commas, brackets or escapes.
- Validate again; once valid, choose Format for readability.
- Test the data against the receiving application's expected fields and types.
FAQ
Can a JSON formatter automatically fix broken data?
No. It can surface parsing errors, but guessing missing or altered values might silently change the meaning of your payload.
Are comments valid inside JSON?
No. Standard JSON has no comment syntax. Some config formats accept comments, but those are different formats or extensions.
Does valid JSON guarantee a valid API request?
No. The structure can parse correctly and still fail an API's schema, authorization or business rules.
Put the explanation into practice
Open the corresponding tool and test with a small, non-sensitive example.