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

Features
- Automatically detects and removes all types of comments
- Preserves strings that contain comment symbols
- Handles inline comments after code
- 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
- Open VS Code
- Go to Extensions tab (
Ctrl+Shift+X or Cmd+Shift+X)
- Search for "Comments Cleaner"
- 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
- 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";
}
| 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
- Check the file language mode (bottom-right corner of VS Code)
- Make sure the file type is supported
Wrong content removed?
- Use
Ctrl+Z / Cmd+Z to undo immediately
- Report the issue with a code sample
Feedback & Contributions
Found a bug or have a suggestion? We'd love to hear from you!
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


Other ways to support:

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