Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>smart-removerNew to Visual Studio Code? Get it now.
smart-remover

smart-remover

Evanroby

|
1 install
| (0) | Free
Just a smart blank line deleter & comment remover
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Smart Comment Remover

A VS Code extension that intelligently removes comments and blank lines from your code while preserving strings, tool directives, and docstrings.

Features

  • Remove All Comments (Smart): Removes comments while preserving:

    • Comment-like characters inside strings (e.g., "https://example.com#anchor")
    • Triple-quoted strings/docstrings in Python
    • Tool directive comments (type hints, linter configs, etc.)
  • Remove All Blank Lines (Smart): Removes empty lines while preserving:

    • Blank lines inside Python docstrings (""" or ''')
    • Blank lines inside JavaScript/TypeScript template literals (backticks)

Supported Languages

  • Python (.py)
  • JavaScript (.js)
  • TypeScript (.ts)
  • JSX/TSX (.jsx, .tsx)
  • HTML (.html)
  • CSS (.css)

Why This Extension?

Most comment removal extensions have a critical flaw: they delete anything after a # or //, even when it's inside a string. This extension properly parses your code to avoid breaking strings.

Example Problem with Other Extensions:

url = "https://example.com#anchor"

❌ Other extensions would break this by removing #anchor, leaving you with:

url = "https://example.com"

This Extension Handles It Correctly:

✅ Preserves # inside Python strings ✅ Preserves // inside JavaScript strings ✅ Preserves blank lines inside docstrings and template literals ✅ Handles escape sequences properly ✅ Preserves tool directive comments (ESLint, TypeScript, Prettier, etc.)

Tool Directive Comments (Preserved)

The extension automatically preserves important directive comments that tools need:

Python Directives

  • Type hints: # type:, # type ignore
  • Linters: # pylint:, # flake8:, # ruff:, # noqa
  • Formatters: # black:, # isort:, # yapep8:
  • Type checkers: # mypy:, # pyright:, # pyre:
  • And many more...

JavaScript/TypeScript Directives

  • TypeScript: // @ts-ignore, // @ts-expect-error
  • ESLint: // eslint-disable, /* eslint-disable */
  • Prettier: // prettier-ignore
  • Testing: // @jest, // @vitest
  • Build tools: /* @__PURE__ */, // @vite
  • Regions: // #region, // #endregion
  • And many more...

Usage

  1. Open a supported file (Python, JavaScript, TypeScript, HTML, or CSS)
  2. Press Ctrl+Shift+P (or Cmd+Shift+P on Mac)
  3. Choose either:
    • Remove All Comments (Smart)
    • Remove All Blank Lines (Smart)

Installation

From VS Code Marketplace

  1. Open VS Code
  2. Go to Extensions (Ctrl+Shift+X)
  3. Search for "Smart Remover"
  4. Click Install

From VSIX File

  1. Download the .vsix file
  2. Open VS Code
  3. Press Ctrl+Shift+P
  4. Type "Install from VSIX"
  5. Select the downloaded file
  6. Reload VS Code

From Source

npm install -g @vscode/vsce
git clone https://github.com/evanroby/smart-remover
cd smart-comment-remover
npm install
vsce package
code --install-extension smart-comment-remover-0.0.4.vsix

Examples

Python: Remove Comments

Before:

def calculate_total(items):
    # Calculate the sum of all items
    total = 0  # Initialize counter
    for item in items:
        total += item  # Add each item
    return total

After:

def calculate_total(items):
    total = 0
    for item in items:
        total += item
    return total

Preserves strings with #:

url = "https://example.com#section"  # This comment is removed
api_key = "abc123#def456"  # But the # in strings stays!

After:

url = "https://example.com#section"
api_key = "abc123#def456"

Preserves directive comments:

def process_data(data: list) -> int:  # type: ignore
    result = sum(data)  # noqa: E501
    return result

After:

def process_data(data: list) -> int:  # type: ignore
    result = sum(data)  # noqa: E501
    return result

JavaScript/TypeScript: Remove Comments

Before:

function fetchData() {
    // Fetch data from API
    const url = "https://api.example.com/data";  // API endpoint
    /*
     * This is a multiline comment
     * explaining the fetch logic
     */
    return fetch(url);
}

After:

function fetchData() {
    const url = "https://api.example.com/data";
    return fetch(url);
}

Preserves directive comments:

// @ts-ignore
const result = riskyOperation();

/* eslint-disable no-console */
console.log("Debug info");

// prettier-ignore
const matrix = [
    1, 2, 3,
    4, 5, 6
];

After:

// @ts-ignore
const result = riskyOperation();

/* eslint-disable no-console */
console.log("Debug info");

// prettier-ignore
const matrix = [
    1, 2, 3,
    4, 5, 6
];

Remove Blank Lines

Python - Before:

def greet(name):

    """
    Greet a person by name.

    This function has blank lines in the docstring.
    """

    message = f"Hello, {name}!"

    print(message)

Python - After:

def greet(name):
    """
    Greet a person by name.

    This function has blank lines in the docstring.
    """
    message = f"Hello, {name}!"
    print(message)

Note: Blank lines inside the docstring are preserved!

JavaScript - Before:

function display() {

    const template = `
        <div>

            <h1>Title</h1>

        </div>
    `;

    render(template);
}

JavaScript - After:

function display() {
    const template = `
        <div>
            <h1>Title</h1>
        </div>
    `;
    render(template);
}

Note: Blank lines inside the template literal are preserved!

Requirements

  • VS Code 1.60.0 or higher

Known Issues

None currently. Please report issues on GitHub.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Release Notes

0.0.4

  • Fixed the README.md
  • Fixed the package.json vscode engines part (feat hardstucksilver_123)

0.0.3

  • Added support for preserving tool directive comments
  • Improved Python multiline string handling

0.0.2

  • Added JSX/TSX support
  • Improved blank line removal logic

0.0.1

  • Initial release
  • Support for Python, JavaScript/TypeScript, HTML/CSS
  • Smart comment removal
  • Smart blank line removal

License

MIT

Author

evanroby

Created to solve the problem of extensions that blindly remove everything after comment characters, even inside strings.


Enjoying this extension? Give it a ⭐ on GitHub!

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