Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Comments CleanerNew to Visual Studio Code? Get it now.
Comments Cleaner

Comments Cleaner

Dionip

|
2 installs
| (0) | Free
Remove all comments without changes the code.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Comments Cleaner

A powerful VS Code extension that removes all comments from your code files while preserving the functional code.

Visual Studio Marketplace Version Visual Studio Marketplace Installs Visual Studio Marketplace Rating

Features

Smart Comment Detection

  • Automatically detects and removes all types of comments
  • Preserves strings that contain comment symbols
  • Handles inline comments after code

Multiple Comment Styles

  • Single-line comments: //, #, --
  • Block comments: /* */, <!-- -->, """, '''
  • Documentation comments: JSDoc, Javadoc, Python docstrings
  • Nested comments: Properly handles nested block comments

Wide Language Support

Supports comments in:

  • JavaScript / TypeScript
  • Python
  • Java / C / C++ / C#
  • Go / Rust
  • HTML / XML / CSS / SCSS / LESS
  • SQL
  • PHP / Ruby
  • Terraform / HCL
  • Shell Script / PowerShell
  • YAML / Dockerfile
  • Plain Text

Safe & Reliable

  • Never removes code, only comments
  • Preserves string literals with comment symbols
  • Handles edge cases like regex patterns and URLs
  • Undo-friendly (Ctrl+Z to restore)

Installation

From VS Code Marketplace

  1. Open VS Code
  2. Go to Extensions tab (Ctrl+Shift+X or Cmd+Shift+X)
  3. Search for "Comments Cleaner"
  4. Click Install

From Command Line

code --install-extension dionip.comments-cleaner

Usage

Keyboard Shortcut (Recommended)

  • Open any code file
  • Press Ctrl+Shift+R (Windows/Linux) or Cmd+Shift+R (Mac)
  • All comments will be removed instantly!

Command Palette

  • Press Ctrl+Shift+P (Windows/Linux) or Cmd+Shift+P (Mac)
  • Type "Remove Comments from File"
  • Press Enter

Context Menu

  • Right-click anywhere in the editor
  • Select "Remove Comments from File"

Examples

Before

// This is a single line comment
const name = "John"; // Inline comment

/* Block comment 
   spanning multiple lines */
const age = 30;

/**
 * JSDoc comment
 * @param {string} text
 */
function greet(text) {
    return "Hello"; // Another comment
}

After

const name = "John";

const age = 30;

function greet(text) {
    return "Hello";
}

Supported Comment Types

Language Single Line Block Comment Documentation
JavaScript/TypeScript // /* */ /** */
Python # """ ''' """
Java/C/C++ // /* */ /** */
HTML/XML - <!-- --> -
CSS/SCSS - /* */ -
SQL -- /* */ -
Terraform/HCL # /* */ -
Shell/Bash # - -
Ruby # =begin =end -
PHP // # /* */ /** */

What Gets Preserved

✅ Safe to keep:

  • All functional code
  • String literals: "This is a // string"
  • URLs: https://example.com
  • Regular expressions: /\/\//
  • Division operators: 10 / 2

❌ Gets removed:

  • Single-line comments
  • Block/multi-line comments
  • Inline comments after code
  • Documentation comments (JSDoc, etc.)
  • Commented-out code

Configuration

Currently, Comments Cleaner works out of the box with no configuration needed. Future versions may include:

  • Option to preserve documentation comments
  • Custom comment patterns
  • Exclude specific file types

Known Limitations

  • Embedded languages: Comments inside <script> and <style> tags in HTML are handled, but other embedded languages may need the file to be in that specific language mode
  • Complex nested comments: Some languages don't support nested comments; the extension handles them as best as possible
  • Custom comment styles: Only standard comment syntaxes are supported

Troubleshooting

Comments not being removed?

  1. Check the file language mode (bottom-right corner of VS Code)
  2. Make sure the file type is supported

Wrong content removed?

  1. Use Ctrl+Z / Cmd+Z to undo immediately
  2. Report the issue with a code sample

Feedback & Contributions

Found a bug or have a suggestion? We'd love to hear from you!

  • 🐛 Report issues
  • 💡 Request features
  • ⭐ Star on GitHub

Support the Project

If you find this extension useful, please consider:

  • ✍️ Leaving a review on the Marketplace
  • 🐛 Reporting bugs and suggesting features

☕ Buy Us a Coffee

Buy Me a Coffee

Ko-fi

Other ways to support:

QR Code 2 QR Code 1

Your support helps us maintain and improve this extension. Thank you! 🙏

Developed with ❤️ by Dioni Pinho

Happy coding without the clutter! 🚀


License

See LICENSE file for details

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft