Skip to content
| Marketplace
Sign in
Visual Studio Code>Formatters>LWC Space CleanerNew to Visual Studio Code? Get it now.
LWC Space Cleaner

LWC Space Cleaner

monoranjan-choudhury

|
3 installs
| (0) | Free
Safely removes trailing spaces and converts leading indentation spaces to tabs in Lightning Web Component .js files only (Aura and all other JS are ignored). JS-aware: lines inside template literals, block comments and strings are never modified, so string values can never change. Provides notificat
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

LWC Space Cleaner

A VS Code extension that safely removes trailing spaces and converts leading indentation spaces → tabs only in Lightning Web Component .js files (anything under an lwc/ folder). Aura components and all other JavaScript are ignored.

Author: Monoranjan Choudhury

Why it is safe

JavaScript is not Apex — whitespace can be part of a string's value. This extension is JS-aware: a line is only modified when its leading/trailing whitespace is in code context. Lines inside template literals, block comments or strings are never touched, so string values can never change.

Features

What How
Clean on save Save an LWC .js file (with changes) → spaces cleaned automatically.
One-click clean ✨ Clean LWC JS status-bar button when an LWC .js is open.
Notifications + Execution Summary Table Every clean shows Spaces, Tabs inserted, JS chars saved and a Protected count (lines left untouched inside templates/comments/strings).
Verify / Fix workspace Command Palette → LWC Space Cleaner: Verify All LWC .js Files (dry run) and Fix All LWC .js Files.

Settings (lwcSpaceCleaner.*)

Setting Default Meaning
enabledOnSave true Clean LWC .js automatically on save.
tabSize 4 Spaces treated as one tab level.
convertLeadingSpacesToTabs true Convert leading spaces to tabs on safe lines.
removeTrailingSpaces true Remove trailing spaces on safe lines.
showSaveNotification true Show a notification when a clean runs.
logEverySave true Log every save to the output channel.
feedbackWhenNoChange true Show the table + notification even when nothing changed.

Install from the .vsix

  1. Extensions view → ⋮ → Install from VSIX... → pick lwc-space-cleaner-1.0.0.vsix.
  2. Reload Window, then open any LWC .js.

Build / package

npm install
npm run compile
npm run package      # → lwc-space-cleaner-1.0.0.vsix
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft