Invisible Character Cleaner
Detects and cleans invisible Unicode characters (zero-width spaces, BOM, non-breaking spaces) and tabs from your files — with a native side-by-side diff view before applying changes.
Perfect for Salesforce developers dealing with the 6M Apex character limit, teams copy-pasting from Confluence/Word, or anyone hunting down mysterious bugs caused by invisible characters.
Why this exists
Invisible characters are silent bugs. They sneak in from:
- Copy-paste from Confluence, Word, Google Docs
- Browser-rendered code blocks with smart quotes
- Multi-language content with directional marks
- Files saved with BOM by older editors
They look fine. They compile fine. They just break things in surprising ways — SOQL queries silently failing, string comparisons not matching, Apex character limit filling up faster than expected.
This extension finds them and cleans them.
Features
- ✅ Auto-scan on file open — flags invisible characters the moment you open a file
- ✅ Auto-scan on file save — catches newly-pasted invisibles every time you save
- ✅ Native diff view — uses VS Code's built-in side-by-side diff, no custom UI to learn
- ✅ Review before apply — always shows you what will change; you approve or cancel
- ✅ Configurable — pick your file extensions, tab replacement, on/off per trigger
- ✅ Output channel logging — exact line/column/hex code for every invisible found
What gets cleaned
| Character |
Unicode |
Action |
| Tab |
\t |
Replaced with 4 spaces (configurable) |
| Non-breaking space |
U+00A0 |
Replaced with regular space |
| Zero-width space |
U+200B |
Removed |
| Zero-width non-joiner |
U+200C |
Removed |
| Zero-width joiner |
U+200D |
Removed |
| Left-to-right mark |
U+200E |
Removed |
| Right-to-left mark |
U+200F |
Removed |
| Line separator |
U+2028 |
Removed |
| Paragraph separator |
U+2029 |
Removed |
| Left-to-right embedding |
U+202A |
Removed |
| Pop directional formatting |
U+202C |
Removed |
| Word joiner |
U+2060 |
Removed |
| Byte order mark |
U+FEFF |
Removed |
Usage
Automatic
Install the extension. Open any file in your configured extension list. If invisible characters are found, a notification appears:
Found 5 invisible character(s) and 2 tab(s) in myClass.cls
[Show Diff] [Clean Now] [Dismiss]
- Show Diff — opens VS Code's native diff editor showing original vs cleaned
- Clean Now — applies the clean immediately and saves
- Dismiss — ignore for now
Manual
Open Command Palette (Ctrl+Shift+P / Cmd+Shift+P) → "Invisible Cleaner: Scan and Clean Current File"
Configuration
Open VS Code Settings and search for "Invisible Cleaner":
| Setting |
Default |
Description |
invisibleCleaner.scanOnOpen |
true |
Auto-scan when files are opened |
invisibleCleaner.scanOnSave |
true |
Auto-scan when files are saved |
invisibleCleaner.tabReplacement |
" " (4 spaces) |
What to replace tabs with |
invisibleCleaner.fileExtensions |
.cls, .trigger, .js, .ts, .html, .css, .txt, .md, .py, .java |
Which extensions to scan |
Leave fileExtensions empty [] to scan all files regardless of extension.
Perfect for Salesforce development
If you're working with Apex and hitting the 6,000,000 character limit per org, invisible characters silently eat into your budget. This extension helps keep your code clean so every character counts toward actual logic, not hidden junk from pasted content.
Works great on:
.cls (Apex classes)
.trigger (Apex triggers)
.js (LWC/Aura JavaScript)
.html (LWC markup)
.css (LWC styles)
Output logging
Every scan logs to the Invisible Cleaner output channel (View → Output → select "Invisible Cleaner"):
[10:23:45] Scanned myClass.cls: 5 invisible(s), 2 tab(s), 12,453 total chars
Line 14, Col 22: U+200B - ZERO WIDTH SPACE
Line 28, Col 1: U+FEFF - BYTE ORDER MARK
Line 42, Col 7: U+00A0 - NO-BREAK SPACE
...
Requirements
Release notes
See CHANGELOG.md.
License
MIT
Author
Built by apexnova — also maker of Apex fflib Generator.
Feedback, issues, and PRs welcome!