Skip to main content
Programming Language Tools

Code Comment Remover

Strip common single-line and block comments from code in several languages - pattern-based, not a full language parser.

Paste your code and choose its language style - this tool strips out single-line and block comments using that language's comment syntax.

This uses pattern matching, not a full language parser - it can occasionally misidentify a comment-like sequence inside a string literal. Review the output before relying on it for anything critical.

Regex/pattern-based comment removal cannot perfectly parse every edge case (like a comment marker inside a string literal) - always review the output before relying on it.

What Does This Tool Do?

It removes comments matching common patterns for a chosen language style - // and /* */ for JavaScript/PHP/CSS-style languages, # for Python/shell-style languages, and -- for SQL.

Why Use This Tool?

Useful for quickly stripping comments from a code snippet before sharing or minifying it, when a full language-specific tool isn't necessary.

How to Use It

  1. Paste your code.
  2. Choose the comment style matching your language.
  3. Copy the comment-stripped result.

Important Notes

This uses pattern matching, not a full language parser - a comment-marker character appearing inside a string literal (e.g. a URL containing //) can be incorrectly treated as a comment start. Always review the output before using it.

Share this tool: