DataToolsLab
Code Formatter Tools

Code Comment Stripper

Remove //, # and /* */ comments from JavaScript, CSS, HTML, Python, SQL or shell source.

Loading tool…

What is Comment Stripper?

A language-aware comment remover, useful for shrinking a snippet, preparing a configuration file for a parser that rejects comments, or checking what a file looks like without its prose.

How it works

Each language gets the scanner that understands it: JavaScript, TypeScript, CSS, HTML, Python, SQL and shell. Strings, template literals, regular expressions and HTML attribute values are skipped, so a `//` inside a URL, a `#` inside a CSS colour or a `--` inside a string literal is never treated as a comment.

  1. Paste the source. Drop in code, a stylesheet, a query or a selector list. Everything is read locally — the page never uploads what you paste.
  2. Choose the options. Indent width, quote style, keyword case or target browsers. The result updates as you change them, so you can see the effect immediately.
  3. Copy or download. Copy the result to the clipboard or download it as a file. Reset clears the form and returns every option to its default.

Examples

A config file that must lose its comments

Stripping a JSONC-style file before feeding it to a strict parser, with the inline explanations removed and the data untouched.

Checking a file's code-only weight

See how much of a heavily commented utility file is comment, which is often a hint that a decision needs documenting elsewhere.

Common mistakes

Expecting a formatter to fix invalid code

Formatting is whitespace and quoting. A missing brace, an unclosed tag or an unquoted variable survives the round trip and is reported instead — check the findings list.

Minifying without running the tests afterwards

Even a safe, non-mangling minifier can expose an existing automatic-semicolon-insertion bug. The JavaScript Minifier keeps the newlines that matter, but re-run your tests before shipping.

Treating a rewritten query as verified

The SQL Dialect Converter translates the syntax it can prove; data types, casts and function differences are listed for review, not guessed. Run the converted query against a real database.

Renaming or reformatting generated files

Regenerating a formatter's output is a no-op only if the formatter is the same one that produced it. Keep generated code out of the round trip and format the source it came from.

Frequently asked questions

Can it strip comments from a language that is not listed?

No — treating `#` or `--` as a comment in the wrong language corrupts data. The seven listed languages cover the common cases; for anything else a language-specific tool is the safe choice.

Will removing doc comments break my types?

Possible in TypeScript and JSDoc-driven projects: a bundler that reads `/** … */` for types or a documentation generator will lose its input. Keep the option to retain licence banners on, and never strip comments from the sources your tooling reads.

Does it remove comments inside strings?

It does not — that is the whole point of using a tokenizer. `"https://example.com"` keeps its `//`, and a Python string containing a `#` keeps its hash.

Online