Remove JSON comments and trailing commas safely
JSONC to JSON converts commented JSON-style configuration into strict JSON. It removes syntax extensions that a standard JSON parser rejects.
When should you use it?
- Share an editor settings file with a strict JSON API.
- Strip explanatory comments from a configuration example.
- Remove trailing commas before validation.
Example: remove JSONC-only syntax
Comments and the trailing comma disappear; the value remains true.
{ // note
"ready": true,
}{"ready":true}Comment markers inside strings are ordinary data
A URL can contain // and a message can contain /* without either starting a comment inside a quoted string. A JSONC parser tracks strings and syntax before removing comments, avoiding the corruption a broad regular expression can cause. The tool also accepts trailing commas, then checks that the result follows strict JSON grammar.
JSONC support does not imply JavaScript expression support
Unquoted names, single-quoted strings, functions, and arbitrary expressions are outside this conversion. Use the original configuration format when comments need to be maintained by people, and generate strict JSON for a consumer that requires it. Keep the commented source separately, because the converted document cannot reconstruct the explanations once they have been removed.
How do I remove comments and trailing commas from JSONC?
Paste a commented JSONC configuration and convert it to strict JSON. The parser accepts comments and trailing commas, then emits the same data without those extensions. Use the result with APIs and libraries that require ordinary JSON.
JSONC input with a comment and trailing comma
jsonc{
// Enable the staging feature.
"enabled": true,
}The strict output is {"enabled":true} after formatting. A standard JSON parser rejects the input because of the comment and final comma.
Will this also convert JavaScript object literals or JSON5?
No. Unquoted names, single-quoted strings, and other JavaScript extensions are outside this JSONC subset. Use Repair for a reviewed suggestion when the input is not valid JSONC.
What should you check before using the result?
This is not a general JavaScript object parser or JSON5 converter. Malformed structure and duplicate names fail instead of being guessed or overwritten.
Understand JSON syntaxTechnical reference: JSONC parser options and supported syntax