What is JSONC / JSON5 and why strip comments?
JSONC is JSON with comments, popularized by VS Code config files like tsconfig.json and settings.json. JSON5 is a broader ES5-flavored superset. Both are convenient to hand-edit but break strict parsers, APIs, and tooling, so you strip them down to valid JSON (RFC 8259) before shipping.
Standard JSON forbids comments, so // and /* */ break JSON.parse. This tool converts JSONC/JSON5 to strict, parseable JSON entirely in your browser, with zero uploads.
Edge cases & gotchas
//or/* */sequences inside string values are content, not comments. They are preserved.- URLs like
http://contain//, so those are never stripped. - JSONC allows trailing commas; strict JSON does not, so they are removed.
- JSON5 single-quoted strings and unquoted keys are re-quoted with double quotes.
- Block comments can span multiple lines; nesting is not allowed in the spec.
- Python-style
None/True/False(common in copy-pasted dict output) map tonull/true/false.
Feature support: JSON vs JSONC vs JSON5
| Feature | JSON | JSONC | JSON5 |
|---|---|---|---|
// and /* */ comments | No | Yes | Yes |
| Trailing commas | No | Yes | Yes |
| Single-quoted strings | No | No | Yes |
| Unquoted keys | No | No | Yes |
| Hex numbers / multi-line strings | No | No | Yes |
How to use
- Paste JSONC or JSON5 into the Input pane.
- The tool auto-detects and removes
//line comments and/* */block comments. - Trailing commas, single quotes, and Python literals (
None/True/False) are repaired too. - Copy the strict JSON output. It validates against
JSON.parse. - Verify zero network calls in DevTools → Network.
Examples
Line + block comments stripped
{
// app name
"name": "api",
"port": 8080 /* default */
}{"name":"api","port":8080}JSON5 → JSON (single quotes, unquoted keys, trailing comma)
{ name: 'api', tags: ['a', 'b',], }{"name":"api","tags":["a","b"]}Edge case: comment tokens inside strings are preserved
{"url": "https://x.com//path", "note": "a /* not a comment */"}{"url":"https://x.com//path","note":"a /* not a comment */"}FAQ
Why doesn't JSON allow comments?
Crockford removed them deliberately so parsers stay simple and comments can't be abused for out-of-band directives.
JSONC vs JSON5?
JSONC = JSON plus comments and trailing commas only (VS Code, tsconfig). JSON5 is a broader ES5-flavored superset adding single quotes, unquoted keys, hex numbers, and multi-line strings.
Can I get the comments back?
No, comments are discarded. Keep your original JSONC source if you still need them.
Does it change my data?
No. Only comments and non-strict syntax are removed; keys and values are unchanged, though formatting may differ. Check the output size with Analyze JSON.
Does it handle trailing commas?
Yes: {"a":1,} becomes {"a":1}.