Skip to content

JSON Comments Stripper — JSONC to Valid JSON

Paste JSON with comments (JSONC) and get clean, strict JSON — removes // line comments, /* block comments */, and trailing commas.

Last updated:

Why JSON with comments exists

The official JSON specification (RFC 8259) does not allow comments. That was a deliberate choice by Douglas Crockford — his intent was a pure data-interchange format, not a configuration language. But in practice, configuration files want comments: a reader needs to know why a setting is there, not just what its value is.

So a dialect called JSONC (JSON with Comments) emerged. VS Code uses it for settings.json, TypeScript uses it for tsconfig.json, and many build tools accept it in their config files. It adds two features to JSON: // and /* */ comments, and trailing commas after the last element of an object or array.

The problem: most JSON parsers (browsers, libraries, APIs) reject JSONC outright. JSON.parse() throws on the first comment. If you want to feed JSONC into a system that expects strict JSON, you have to strip the comments first — that's what this tool does.

What this tool removes

  • Line comments// through end of line, including inline trailing comments on the same line as a value.
  • Block comments/* ... */ across any number of lines. Unterminated block comments remove everything to end of input.
  • Trailing commas — the comma after the last item in an object or array. Toggleable — disable if your target parser accepts them.

Strings are fully respected. A URL like "https://example.com" or a message like "see /* below */" is preserved verbatim — only comments outside strings are stripped. Escaped quotes inside strings are tracked so the scanner never breaks out early.

When you'll actually reach for this

  • Feeding tsconfig.json into a tool that wants strict JSON. Many CI pipelines and Node scripts call JSON.parse() directly on a tsconfig and fail until the comments are gone.
  • Copying a VS Code settings.json snippet into a JSON validator. The file is JSONC by design but external tools usually aren't.
  • Preparing a configuration blob for an API that accepts only JSON. Webhook payloads, GraphQL variables, or REST request bodies almost always need strict JSON on the wire.
  • Cleaning up a JSON example copy-pasted from a blog post or documentation page where the author added explanatory // ... notes.

After stripping, pipe the result through our JSON Formatter for a pretty-printed, validated version.

JSONC vs JSON5 vs HJSON

Several "JSON with more stuff" dialects exist. They're easy to confuse:

  • JSONC — JSON + comments + trailing commas. That's it. Most widely supported because the delta is small. VS Code, TypeScript, and most build tools speak it.
  • JSON5 — a larger extension: comments, trailing commas, single-quoted strings, unquoted keys, hex numbers, Infinity/NaN, and more. More ergonomic but less universally supported.
  • HJSON — human-friendly JSON with optional quotes, multiline strings, and comments. Used less often in tooling but some configs accept it.

This tool targets JSONC specifically — the most common "JSON with comments" dialect in practice. It will also strip comments out of JSON5, but won't translate single-quoted strings or unquoted keys to strict JSON.

Related JSON tools on CodeBoxTools

Frequently Asked Questions

Does JSON support comments?
No. The official JSON specification (RFC 8259) does not allow comments. Douglas Crockford intentionally excluded them so JSON would stay a pure data-interchange format. Tools like VS Code and TypeScript use a dialect called JSONC that adds comments and trailing commas on top of JSON.
What is JSONC?
JSONC is JSON with Comments. It extends standard JSON with two features: // line comments, /* */ block comments, and trailing commas after the last element in objects and arrays. VS Code's settings.json and TypeScript's tsconfig.json both use JSONC.
How do I convert JSONC to JSON?
Paste the JSONC into the tool above. It strips line and block comments, optionally removes trailing commas, and validates the result with JSON.parse(). Copy the output and use it anywhere strict JSON is required.
Does this remove comments inside strings?
No. The tool tracks string-literal state as it scans. Anything inside a "..." pair is preserved verbatim — a URL like "https://example.com" or a message containing // or /* */ stays intact.
What about trailing commas?
Trailing commas are removed by default because most strict JSON parsers reject them. Toggle the Remove trailing commas button off if your target parser accepts them (JSON5, relaxed JSON parsers, etc.).
Will this work on JSON5?
Partially. This tool removes the comments and trailing commas that JSON5 shares with JSONC, but it won't translate JSON5-specific features like single-quoted strings, unquoted keys, or hex numbers. For full JSON5 support, use a dedicated JSON5 parser.
Is my data safe?
Yes. The tool runs entirely in your browser — no uploads, no tracking, no server calls. Paste sensitive configs freely.

Related Tools