JSONC: JSON with Comments
JSONC commonly means “JSON with Comments.” It is used by tools and configuration systems that want JSON-like syntax with comments, and some implementations also allow trailing commas. JSONC is not interchangeable with strict JSON unless the parser explicitly supports it.
Quick answer
A file can be valid JSONC and invalid JSON. Remove comments and any unsupported relaxed syntax before sending JSONC content to a strict JSON parser or API.
Where JSONC appears
Developer tooling frequently uses JSONC for editable settings because comments make configuration easier to document. The exact accepted syntax depends on the parser, so JSONC should be treated as a parser-specific format rather than assumed universal JSON.
Comments break strict JSON
The JSON grammar has no // or /* */ comment syntax. A strict parser encounters the slash as an unexpected token. This is why copying settings files directly into an API body often fails.
Do not remove comments with a naive regex
Comment markers can appear inside quoted strings and URLs. A parser-aware transformation is safer than globally deleting text after // or between /* and */.
Typical JSONC configuration
{
// Editor preference
"theme": "dark",
"autosave": true
}Related JSON tools and guides
Frequently asked questions
Is JSONC valid JSON?
Not when it contains comments or other syntax that strict JSON does not allow.
Does JSONC always allow trailing commas?
That depends on the parser. Check the tool or library specification.
Can browsers parse JSONC with JSON.parse?
No. JSON.parse expects strict JSON.