JSON syntax error guide

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

Typical parser message
SyntaxError at / when JSON contains a comment

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.

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 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.