{ } JSON Workbench0 network requests. Check DevTools

"Remove Comments from JSON":{ }

Standard JSON (RFC 8259) forbids comments, so // and /* */ break JSON.parse. Paste JSONC or JSON5 and this tool strips comments (plus trailing commas and single quotes) to output strict, parseable JSON. 100% in your browser, zero uploads.

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 to null/true/false.

Feature support: JSON vs JSONC vs JSON5

FeatureJSONJSONCJSON5
// and /* */ commentsNoYesYes
Trailing commasNoYesYes
Single-quoted stringsNoNoYes
Unquoted keysNoNoYes
Hex numbers / multi-line stringsNoNoYes

How to use

  1. Paste JSONC or JSON5 into the Input pane.
  2. The tool auto-detects and removes // line comments and /* */ block comments.
  3. Trailing commas, single quotes, and Python literals (None/True/False) are repaired too.
  4. Copy the strict JSON output. It validates against JSON.parse.
  5. Verify zero network calls in DevTools → Network.

Examples

Line + block comments stripped

Input
{
  // app name
  "name": "api",
  "port": 8080 /* default */
}
Output
{"name":"api","port":8080}

JSON5 → JSON (single quotes, unquoted keys, trailing comma)

Input
{ name: 'api', tags: ['a', 'b',], }
Output
{"name":"api","tags":["a","b"]}

Edge case: comment tokens inside strings are preserved

Input
{"url": "https://x.com//path", "note": "a /* not a comment */"}
Output
{"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}.

Related tools