JSON Copilot

Can you use comments in JSON?

Advanced Topics

No. Standard JSON does not support comments. The format was intentionally kept minimal for data interchange, so // and /* */ will cause a parse error. There are, however, a few common workarounds.

This is invalid JSON

{
  // the user's name
  "name": "Ada"
}

Workarounds

  • Use a "comment" key: add a harmless field like "_comment": "note here" that your code ignores.
  • Use JSONC or JSON5: relaxed supersets that allow comments. Many tools (VS Code settings, tsconfig.json) use JSONC.
  • Strip comments before parsing: some loaders remove comments first, but standard JSON.parse will not.

If you need comments for configuration humans edit by hand, consider YAML, which supports them natively.

Getting an error from a stray comment? The JSON validator points to the exact line.

Still Have Questions?

Check out our other FAQ topics or return to the JSON Copilot app