How to use the JSONC to JSON converter
- Paste your file into the Input box. The sample is a VS Code settings file with both comment styles and trailing commas.
- Choose the Indent: 2 spaces, 4 spaces, Tab or Minified.
- Copy the JSON or download it as
settings.json. - If something else is wrong, the error names the line and column.
What it does and when to use it
Comments make config files easier to maintain, but many programs only read strict JSON: jq, Python’s json module, most API clients, CI scripts and online validators. When you need to feed a tsconfig.json, an .eslintrc.json or a VS Code settings.json into one of those, this tool removes the parts they reject and leaves the data untouched. It also serves as a cleaner when you paste a commented example from documentation into a project that forbids comments.
After converting, you can check the structure with the JSON validator or turn it into other formats with JSON to YAML or JSON to TOML.
How it works
The tool runs in your browser in three steps:
- Strip comments and trailing commas. It walks through the text character by character. Inside a string it copies everything up to the closing quote, respecting backslash escapes. Outside strings,
//to the end of the line is dropped, and/* … */is replaced with spaces and its line breaks. - Trailing commas are handled in the same walk: a comma outside a string followed only by whitespace or comments and then
}or]is removed. - Parse and print. The result goes through
JSON.parse, thenJSON.stringifywith your indent. Errors are reported with a line and column from the tool’s own JSON scanner.
Worked examples
These are the tool’s own outputs.
The sample settings file. The // editor settings and /* hide VCS */ comments and both trailing commas disappear, while //not-a-comment inside the URL string stays:
"files.exclude": {
"**/.git": true,
"**/node_modules": true
},
"url": "https://toolsrift.com//not-a-comment"
A tsconfig, minified. This JSONC:
{
"compilerOptions": {
/* modern output */
"target": "ES2022",
"strict": true, // always
},
"include": ["src",],
}
becomes {"compilerOptions":{"target":"ES2022","strict":true},"include":["src"]}.
A single-quoted string. A file with // name on line 2 and "a": 'single' on line 3 returns “Invalid JSON at line 3, column 8”, pointing at the single quote. Comments are not the problem there, so the line number matches the original.
Limits and tips
- The comments are gone for good. Keep the JSONC file as your source and generate the JSON copy when needed.
- Key order and values are kept, but the formatting is fully rewritten.
- Duplicate keys are not reported;
JSON.parsekeeps the last one.
Frequently asked questions
What is JSONC?
Is // inside a string treated as a comment?
Why does the error point to the right line of my original file?
Does it accept JSON5 features like single quotes or unquoted keys?
Can a string value be changed by mistake?
How do we know nothing is uploaded? Test it yourself on the privacy proof page.