Comments Are Not Allowed in JSON: What It Means and How to Fix It
The JSON standard has no comment syntax. JavaScript-style // comments and /* block comments */ make a document invalid for strict JSON parsers.
What this JSON error means
SyntaxError at / when JSON contains a commentRemove comments for portable JSON. If comments are a real product requirement, use a format that explicitly supports them rather than depending on a permissive parser.
Broken JSON vs. corrected JSON
Compare the invalid syntax with a corrected version before applying the same change to your payload.
Invalid JSON
{
// primary user
"name":"Ada"
}Valid JSON
{
"name":"Ada"
}Common causes of this JSON error
- ●Treating JSON like a JavaScript configuration file
- ●Copying JSONC from tools such as VS Code settings
- ●Adding inline documentation to API payloads
- ●Using a permissive parser locally while production uses a strict parser
Fix and validate your JSON
After correcting the suspected syntax, run the complete payload through a validator. If it still fails, use the diagnostic tool to locate the next parser error before formatting the final JSON.
Related JSON errors
JSON Unexpected Token Error
Understand and fix JSON unexpected token errors. See broken and corrected examples, common causes, and a fast workflow for finding the exact invalid character.
Unexpected End of JSON Input
Fix “Unexpected end of JSON input” errors caused by truncated JSON, missing braces or brackets, incomplete strings, and empty API responses.
Trailing Comma in JSON
Learn why trailing commas are invalid in standard JSON and fix objects or arrays copied from JavaScript, TypeScript, JSON5, or configuration files.
Single Quotes in JSON
Fix invalid JSON that uses single quotes. JSON requires double quotes around property names and string values.
JSON Property Names Must Be Double-Quoted
Fix JSON with unquoted object keys. Standard JSON requires every property name to be enclosed in double quotes.
Invalid Escape Character in JSON
Fix invalid JSON escape sequences in Windows paths, regex strings, copied text, and backslash-heavy values.
JSON error FAQ
What does Comments Are Not Allowed in JSON mean?
The JSON standard has no comment syntax. JavaScript-style // comments and /* block comments */ make a document invalid for strict JSON parsers.
How do I fix Comments Are Not Allowed in JSON?
Remove comments for portable JSON. If comments are a real product requirement, use a format that explicitly supports them rather than depending on a permissive parser.