Input
- Size
- 0 B
- Lines
- 0
- Keys
- 0
- Depth
- 0
JSONC comments are not RFC 8259 JSON
JSON.parse follows RFC 8259. A comment is not a value, so // note and /* note */ outside a string make the text invalid JSON. TypeScript's tsconfig.json, VS Code settings, and JSONC files use those comments anyway. This page runs the same Auto-Fix scanner as the formatter and writes a comment-free result in the browser.
Line comment
Before: { // editor only\n "strict": true }. After Auto-Fix: {\n "strict": true\n}. The scanner drops characters from // through the end of that line, then parses the rest.
Block comment
Before: { "target": "ES2022" /* emit modern JavaScript */ }. After Auto-Fix the block comment is gone and the key stays. A comment marker inside a string, such as "keep // this", stays part of the string.
Beautify still refuses the original JSONC and reports the line and column. Use Auto-Fix when you want the comments removed. Trailing commas and single quotes in the same file are repaired by the same pass. See Fix trailing comma in JSON for that case on its own.
Frequently Asked Questions
Why does JSON.parse reject comments?
RFC 8259 JSON has no comment syntax. A // or /* */ comment outside a string is invalid, even when TypeScript or an editor accepts that file as JSONC.
Does removing comments upload the JSON?
No. The sample and anything you paste or open from a local .json file are repaired in this browser. Nothing is sent to a server.
Which comments does Auto-Fix remove?
It removes // comments through the end of the line and /* */ block comments when those markers sit outside a string. Then it parses the result as JSON.
Does a comment inside a string stay?
Yes. Comment markers inside a quoted string stay part of that string. Only comments outside strings are stripped.
What is left after the comments are removed?
A formatted JSON value that JSON.parse accepts. Keys, strings, numbers, arrays, and objects stay. The status line reports how many comments were removed.