JSON QuickFix › Remove comments from JSON

Remove comments from JSON

Files like tsconfig.json and VS Code's settings.json allow comments, but most tools and APIs don't. Paste the file below and press Quick Fix to remove every comment and trailing comma while keeping URLs and other text inside strings untouched.

Input

Paste some JSON, drop a .json file, or load the sample to get started.
Advertisement

JSON vs JSONC

Standard JSON has no comment syntax. Its author left comments out deliberately so the format stayed simple to parse. Many developer tools use an extended format called JSONC (JSON with Comments) that also allows trailing commas. That works inside those tools, but feeding the same file to JSON.parse, jq, Python or an API fails.

Why a regex isn't enough

A pattern like //.* also deletes the end of every URL in your file, because https:// contains //. Quick Fix tokenizes the input, so it removes only real comments outside strings and keeps values like "https://example.com" exactly as written.

Keeping notes in strict JSON

If you need documentation inside strict JSON, a common convention is a dedicated key, for example "_comment": "why this value is set", which every parser accepts.

Advertisement

Frequently asked questions

Does JSON support comments?

No. Standard JSON (RFC 8259) has no comments. JSONC, JSON5 and some tools' config files allow them, but strict parsers reject them.

Will URLs with // be damaged?

No. Quick Fix only removes comments that are outside strings, so text such as https:// inside a value is kept.

Can I convert tsconfig.json to plain JSON?

Yes. Paste it in and press Quick Fix: comments and trailing commas are removed and the result is strict JSON.