Skip to content
| Marketplace
Sign in
Visual Studio Code>Formatters>Comment SweepNew to Visual Studio Code? Get it now.
Comment Sweep

Comment Sweep

Salman Asu

|
1 install
| (0) | Free
Removes single-line and multi-line comments from code in any language, without touching strings, code, or other content.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Comment Sweep

Removes single-line and multi-line comments from your code — for basically any language — without touching strings, URLs, or actual code that happens to contain //, #, <!--, etc.

What it handles

  • Line comments: //, #, --, ;, ' (VB), depending on language
  • Block comments: /* ... */, <!-- ... -->, <# ... #>, =begin/=end, --[[ ]]
  • 30+ languages out of the box: JS/TS/JSX/TSX, Python, Java, C/C++/C#, Go, Rust, PHP, Ruby, HTML/XML, CSS/SCSS/LESS, Markdown, YAML, Shell, PowerShell, SQL, Lua, Dockerfile, Makefile, Vue, and more.
  • Unrecognized file types fall back to // + /* */ (the most common style).

What it will NOT touch

  • Anything inside string literals ("...", '...', `...`), even if it contains //, #, or other comment-like text.
  • A leading shebang line (#!/usr/bin/env node) is always preserved.
  • Actual code — only the comment text and comment-only lines are removed.

Installation (no publishing required)

  1. Unzip the extension folder somewhere permanent, e.g. ~/comment-sweep.

  2. Open a terminal in that folder and run:

    npm install -g @vscode/vsce
    vsce package
    

    This produces comment-sweep-1.0.0.vsix.

  3. In VS Code: open the Extensions panel → click the ... menu (top right) → Install from VSIX... → select the .vsix file you just built.

    (Alternatively, skip packaging entirely: copy the whole comment-sweep folder into your VS Code extensions directory — ~/.vscode/extensions/ on macOS/Linux, %USERPROFILE%\.vscode\extensions\ on Windows — then restart VS Code.)

Usage

  1. Open any file in VS Code.
  2. Run Comment Sweep: Remove Comments from File from the Command Palette (Ctrl+Shift+P / Cmd+Shift+P), or right-click in the editor and pick it from the context menu.
  3. To clean only part of a file: select the text first, then run Comment Sweep: Remove Comments from Selection the same way.

Undo (Ctrl+Z / Cmd+Z) works as normal if you want the comments back.

Keyboard shortcuts

Command Windows/Linux macOS
Remove Comments from File Ctrl+Alt+C Cmd+Alt+C
Remove Comments from Selection Ctrl+Alt+Shift+C Cmd+Alt+Shift+C

To change these: Command Palette → Preferences: Open Keyboard Shortcuts → search "Comment Sweep" → click the pencil icon next to a command.

Known limitations

  • Regex literals in JS/TS that contain // inside them (e.g. /a\/\/b/) aren't specially detected — this is a rare edge case; check code with inline regex after running.
  • JSON files are left untouched (standard JSON has no comment syntax); .jsonc files are supported.
  • Python/Ruby "block comments" via triple-quoted strings are treated as strings (correctly) — only #/=begin/=end style comments are removed.

License

MIT

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