Common syntax errors and precise fixes
JSON is stricter than a JavaScript object literal. These compact examples show invalid input on the left and corrected JSON on the right. Each left sample is intentionally invalid.
Missing comma
Separate adjacent properties with a comma.
{
"name": "Ravi"
"active": true
}{
"name": "Ravi",
"active": true
}Trailing comma
Remove the comma after the final array item or property.
["queued", "sent",]["queued", "sent"]Single quotes or unquoted keys
JSON requires double quotes around keys and string values.
{ name: 'Ravi' }{ "name": "Ravi" }Missing closing bracket
Match every opening { or [ with its correct closing delimiter.
{
"items": [1, 2
}{
"items": [1, 2]
}Invalid escape
A backslash begins an escape. To represent a literal backslash, write \\.
{ "path": "C:\q\report" }{ "path": "C:\\q\\report" }Comments and wrong literals
Remove comments; use lowercase true, false, and null. JSON has no undefined value.
{
// cached result
"ready": True
}{
"ready": true
}Escaping quotes and control characters
Inside a JSON string, a quotation mark must be escaped as \", and a literal backslash as \\. Newline and tab characters should be represented by \n and \t. Raw line breaks and other unescaped control characters cannot appear inside a JSON string.
{
"message": "The file is at C:\\temp\\report.json",
"note": "She said \"ready\"."
}A repeatable debugging checklist
- Start with the first parser error; note its line and column if available.
- Inspect a few characters before that location, not only the highlighted token.
- Check quotes first, then commas and matching braces or brackets.
- Remove comments and trailing commas; JSON does not allow either.
- Parse again after each focused edit so new errors are easier to isolate.
- Once it parses, validate expected fields and types separately.
Syntax errors versus application errors
A syntax error means the text cannot be parsed as JSON at all. An application-level problem happens after parsing: perhaps userId is absent, a timestamp is in the wrong format, or a server returned an error object your code did not expect. A JSON parser cannot determine whether your business rules are satisfied.
Parser locations are useful clues, but they are not always the exact character you need to edit. The parser reports where it could no longer continue; if a quote was never closed, the error may point near the end of the string or document. Some runtimes report an offset rather than a line and column. Inspect the surrounding characters and remember that an offset can count bytes or code units rather than the characters you see on screen.
When the message says “unexpected end,” first check whether the response was truncated during copying or transmission. Avoid guessing at a closing brace if fields or array items may also be missing. Compare the received body with a fresh response or the source file; a payload that parses after one guessed bracket can still be incomplete.
Use the JSON Fixer when you want help repairing common malformed input, then inspect the result in the JSON Viewer. If formatting is the only problem, read how to format JSON online.