Code comment stripper
Remove comments from JavaScript, TypeScript, CSS, HTML, SQL and Python code, with optional line-number preservation and removal stats.
Runs in your browserEvery computation happens in your browser — your data never leaves this device.
Lines removed: 0 · Characters removed: 0 · Total lines: 0
What this tool does
- Strip debug comments and leftover console.log notes before a commit so the diff only shows real changes.
- Measure how much of a source file is comments by removing them and comparing the character counts.
- Prepare a clean snippet for docs or a blog post — no comment markers to break the layout when you paste it.
- Handle SQL, Python, CSS and HTML in one place instead of switching tools for each comment syntax.
Example
Input
// header const a = 1; // trailing /* block */ console.log(a);
Output
\nconst a = 1; \n\nconsole.log(a);
Stats reported: 2 lines removed, 21 characters removed, 4 total lines. Newlines inside comments are dropped by default; with "keep line numbers" they stay as blank lines so the output has the same line count as the input.
Frequently asked questions
Will a // inside a string be removed?
Not by default. With "protect comment markers inside strings" enabled, content inside single quotes, double quotes and backticks (plus Python triple quotes) is copied verbatim, so the // in "https://a.com" is safe. Untick it and the scan is purely textual, so the URL gets cut at the //.
Why do I get an unterminated comment error?
The scanner found /* or <!-- without a matching */ or -->, which usually means the input is truncated — a half-copied file, for instance. The tool reports the error instead of guessing where the comment should end, so trailing code is never silently deleted.
Which comment markers does each language use?
JavaScript and TypeScript use // and /* */, CSS only block comments, HTML uses <!-- -->, SQL uses -- and /* */, and Python uses # plus triple-quoted strings. Picking the wrong language shows up immediately as comments left behind or code cut short.
Are Python triple-quoted strings removed?
No. A triple-quoted literal can be a docstring or a real string, so it is treated as a string and kept verbatim; only # line comments are deleted. Docstrings have to be removed by hand.
Can stripping comments break my code?
The scan is character by character and never rewrites or reflows the code itself. It also cannot tell a regex literal containing // apart from a comment, so run your tests or a build afterwards. Everything happens locally — your code is never uploaded.
Keywords:注释去注释commentstrip commentsremove comments代码清理javascriptpythonsqlhtml