The Short Answer: No
The JSON standard (RFC 8259) has no comments. Both // line and /* block */ comments make JSON invalid, and strict parsers like JSON.parse or Python's json.loads will throw an error.
{
// The user's display name
"name": "Emily",
"theme": "dark" /* light or dark */
}Douglas Crockford, who described JSON, left comments out on purpose so people could not use them to hide parsing instructions, and so every JSON parser would behave the same way.
Where Comments Do Work
- JSONC ("JSON with comments"): used by VS Code settings,
tsconfig.jsonandjsconfig.json. - JSON5: a JSON superset with comments, trailing commas and single quotes.
- YAML: a different format that supports
# commentsand is common for config files.
These files only work with tools that expect them. If you send them to a normal JSON parser or an API, they will fail. To tidy up such a file without losing its comments, use the JSON5 and JSONC Formatter.
How to Remove Comments from JSON
Paste the file into our JSON Repair tool or the JSON Formatter. Both remove // and /* */ comments automatically and also fix trailing commas, so you get valid JSON in one click.
Alternatives to Comments
1. A comment field
{
"_comment": "Theme can be light or dark",
"name": "Emily",
"theme": "dark"
}Simple and valid, but the field becomes part of your data, so make sure your code ignores it.
2. A description in a JSON Schema
Put explanations in a separate JSON Schemausing the description keyword. Editors like VS Code then show the description as a tooltip.
3. Use YAML for config files
If people need to edit the file by hand and leave notes, YAML may be the better choice. Convert with our JSON to YAML tool.
4. Keep notes in the README
Document what each field means next to the file, in your project's README or docs.
5. Use YAML for hand-edited config
If people edit the file by hand and need comments, YAML may be a better fit: it supports # comments and holds the same data. Convert with JSON to YAML, and read JSON vs YAML to decide.
Frequently Asked Questions
Does JSON support comments?
No. Standard JSON (RFC 8259) does not allow // or /* */ comments. A strict parser will reject them.
Why do some JSON files have comments?
Some tools accept extended formats such as JSONC (used by VS Code and tsconfig.json) or JSON5. These are not plain JSON.
How do I remove comments from JSON?
Paste the file into our JSON Formatter or JSON Repair tool. It removes // and /* */ comments automatically and gives you valid JSON.
What can I use instead of comments?
Add a field such as "_comment" or "description", keep notes in a README, or use a format that supports comments, like YAML or JSON5, for config files.