Standard JSON has no comments. Files like tsconfig.json, VS Code settings.json and many other config files are actually JSONC (JSON with Comments), which also allows trailing commas. Strict parsers such as JSON.parse, Python's json and jq reject them.
Paste a JSONC file above and press Fix. // line comments, /* */ block comments, # comments and trailing commas are all removed, leaving valid JSON.
Example
{
// Editor settings
"editor.tabSize": 2,
/* format on save */
"editor.formatOnSave": true,
}{
"editor.tabSize": 2,
"editor.formatOnSave": true
}Comments inside strings are safe
Removal is string-aware: a URL like "https://example.com" or a value containing /* inside quotes is left alone. Only comments outside strings are removed.
Why JSON has no comments
JSON's creator left comments out on purpose so people would not use them for parsing directives. If you need comments in a config file, use a format that supports them (JSONC, JSON5, YAML or TOML) and convert to strict JSON when a tool requires it.
Keeping the information
If a comment holds information you need to keep, move it into the data before converting, for example as a "_comment" key. Converted output contains only the data.
Frequently asked questions
Is tsconfig.json valid JSON?
Not always. TypeScript reads tsconfig.json as JSONC, so comments and trailing commas are allowed there but rejected by strict JSON parsers.
Does it remove # comments too?
Yes. Lines starting with # outside strings are removed, along with // and /* */ comments.