Code Comment Stripper (JS, CSS, Python, SQL, HTML, Shell)

Deletes comments from C-style code, CSS, Python, shell, SQL and HTML/XML. Text inside strings is left alone, license comments can be kept, and lines that become empty can be dropped.

Use the tool

Why this tool exists

You may want to share code without notes, shrink a file by hand or count only real code. A search and replace on // breaks every URL in a string.

The tool walks the text and tracks strings, so "http://x" survives. It is a scanner, not a parser: JavaScript regex literals are handled by a heuristic, and shell comments, heredocs or Python f-strings with nested quotes can confuse it. Check the output before you use it, and keep the original.

How to use it

  1. Paste the code and choose the language.
  2. Decide whether to keep license comments and remove empty lines.
  3. Copy the result.
  4. Run your own syntax check on it.

Frequently asked questions

Are strings safe?

Yes for normal strings. Comment markers inside them are kept.

What counts as a license comment?

Block comments starting /*! or /** and anything containing @license or @preserve.

Does it handle regex literals?

By heuristic only. A regex after an operator or bracket is skipped, which is right for common code.

Is Python docstring text removed?

No. Docstrings are strings, so they are kept.