Extension and Workspace Cleaner
Find stale VS Code extension version folders and workspace storage entries, review them in a visual report, and move selected folders to the system Recycle Bin or Trash.
中文说明见下方:中文
Features
- Scan installed extension version folders across common VS Code, VS Code Insiders, VS Code OSS, and VSCodium locations.
- Show which named profiles use each extension version.
- Identify extension folders that are only present in the extension registry or are otherwise likely stale.
- Scan
workspaceStorage and find cached workspace state whose original folder or .code-workspace file no longer exists.
- Show file size and selected total size before cleanup.
- Move selected folders to the OS Recycle Bin or Trash after confirmation.
Installation
Install from the VS Code Marketplace by searching for Extension and Workspace Cleaner in the Extensions view.
To install from a .vsix file:
- In VS Code, open the Extensions view, choose
..., then choose Install from VSIX....
- Or run
code --install-extension <file>.vsix from a terminal.
Commands
Open the Command Palette and run one of these commands:
Extension and Workspace Cleaner: Scan Unused Extension Versions
Extension and Workspace Cleaner: Scan Workspace Storage
The commands open separate report pages. Scanning does not remove anything.
Extension Cleanup
Run Extension and Workspace Cleaner: Scan Unused Extension Versions.
The report shows one row per installed extension version:
- Extension name, ID, version, and file size
- Status
- Profiles that explicitly use this version
- Profiles that reference the extension without recording a version, if such references exist
Status values:
Profile Used: a scanned profile explicitly references this exact extension version.
Protected: a profile references the extension ID without recording a version, so the latest installed version for that channel is kept.
Registry Only: VS Code's extension registry records the folder, but no scanned named profile references it. If you confirm the Default/built-in Profile does not use it, it is safe to move to the Recycle Bin or Trash.
Cleanup Candidate: no scanned profile references the folder.
Unclear: the folder did not match a cleanup rule.
Notes:
- Named profile metadata is read from
User/profiles/<id>/extensions.json.
- Profile names are resolved from
User/globalStorage/storage.json when available.
- Application-scoped and machine-scoped extensions are shown as
All Profiles (...) because they apply across profiles and may not appear in individual named profile files.
- VS Code does not store Default/built-in Profile extension membership in a simple
User/extensions.json file, so registry-only items should be checked against the Default/built-in Profile before cleanup.
- If a profile references only an extension ID without a version, the report treats it as a reference to the latest installed version in that channel. If both stable and preview builds exist, the latest stable and latest preview may both be protected.
Select the rows you want to remove, then choose Move selected to Recycle Bin.
Workspace Storage Cleanup
Run Extension and Workspace Cleaner: Scan Workspace Storage.
The report scans User/workspaceStorage/<id> folders, reads each workspace.json, and checks whether the recorded local folder or .code-workspace file still exists.
Status values:
Missing: the recorded local folder or .code-workspace file no longer exists.
Exists: the recorded local path still exists.
Unknown: the storage entry has no readable workspace target metadata.
Unsupported: the target URI is not a local file: URI, so local existence was not checked.
You can select missing entries or manually select any entries, including valid workspaces, then choose Move selected to Recycle Bin.
Cleaning workspace storage removes VS Code cached state only. It does not delete your project folder or .code-workspace file.
Sorting and Selection
- Reports are sorted by
Status by default.
- Click sortable headers such as
Status, File Size, Extension Version, or Workspace to change the order.
- Both reports show the currently selected total file size before cleanup.
- Long details are collapsed; hover or expand
Details to inspect full paths and reasons.
Safety
The extension does not permanently delete selected folders directly. Cleanup uses VS Code's file service with trash enabled, so selected folders are moved to the system Recycle Bin or Trash.
If the OS or current VS Code environment cannot move an item to trash, cleanup fails and the error is shown in the Extension and Workspace Cleaner output channel.
Settings
extensionWorkspaceCleaner.extensionDirectories: override extension folders to scan.
extensionWorkspaceCleaner.userDataDirectories: override VS Code User folders to scan.
Use these settings if you start VS Code with custom --extensions-dir or --user-data-dir paths.
Default Scan Locations
The extension scans common locations when they exist, including:
- Windows extension folders:
%USERPROFILE%\.vscode\extensions
- Windows user data:
%APPDATA%\Code\User
- macOS user data:
~/Library/Application Support/Code/User
- Linux user data:
$XDG_CONFIG_HOME/Code/User or ~/.config/Code/User
Limitations
- VS Code extensions cannot reliably read the original
--user-data-dir or --extensions-dir command-line arguments. Configure custom paths manually if needed.
- Remote environments such as WSL, SSH, Dev Containers, and Codespaces have separate extension and workspace storage locations.
- Snap or Flatpak builds on Linux may use non-standard directories.
中文
Extension and Workspace Cleaner 用于查找 VS Code 中遗留的扩展版本目录和 workspaceStorage 缓存目录,并通过图形化报告让你确认后移动到系统回收站。
功能
- 扫描常见 VS Code、VS Code Insiders、VS Code OSS、VSCodium 扩展安装目录。
- 显示每个扩展版本被哪些 named profile 使用。
- 标记只存在于扩展安装注册表中、或疑似遗留的扩展目录。
- 扫描
workspaceStorage,找出原始项目目录或 .code-workspace 文件已经不存在的缓存。
- 显示每项大小和当前已选中的总大小。
- 删除前二次确认,并移动到系统回收站,而不是直接永久删除。
安装
可以在 VS Code 扩展市场中搜索 Extension and Workspace Cleaner 并安装。
如果你拿到的是 .vsix 文件,可以使用以下方式安装:
- 在 VS Code 扩展视图中点击
...,选择 Install from VSIX...。
- 或在终端运行
code --install-extension <file>.vsix。
命令
打开 Command Palette,运行以下命令之一:
Extension and Workspace Cleaner: Scan Unused Extension Versions
Extension and Workspace Cleaner: Scan Workspace Storage
两个命令会打开不同的报告页面。扫描过程不会删除任何内容。
清理扩展版本
运行 Extension and Workspace Cleaner: Scan Unused Extension Versions。
报告中每一行代表一个已安装的扩展版本,包含:
- 扩展名称、ID、版本和文件大小
- 状态
- 明确使用该版本的 Profile
- 只记录扩展 ID、没有记录版本的 Profile,如果存在才显示
状态说明:
Profile Used:某个扫描到的 Profile 明确引用了这个扩展版本。
Protected:某个 Profile 只引用扩展 ID、没有记录版本,因此保留该通道下最新安装版本。
Registry Only:VS Code 扩展注册表记录了该目录,但扫描到的 named profile 没有引用它。如果你确认 Default/built-in Profile 没有使用它,就可以安全移动到回收站。
Cleanup Candidate:没有扫描到任何 Profile 引用该目录。
Unclear:该目录没有匹配到明确的清理规则。
补充说明:
- named profile 元数据来自
User/profiles/<id>/extensions.json。
- Profile 名称会尽量从
User/globalStorage/storage.json 解析。
- application-scoped 和 machine-scoped 扩展会显示为
All Profiles (...),因为它们作用于所有 Profile,可能不会出现在单个 named profile 文件中。
- VS Code 并没有简单的
User/extensions.json 用来表示 Default/built-in Profile 的扩展清单,因此 Registry Only 项需要你结合 Default/built-in Profile 手动确认。
- 如果 Profile 只记录扩展 ID、不记录版本,报告会把它视为引用该通道下最新安装版本。如果 stable 和 preview 同时存在,最新 stable 和最新 preview 都可能被保护。
选择要清理的行,然后点击 Move selected to Recycle Bin。
清理 Workspace Storage
运行 Extension and Workspace Cleaner: Scan Workspace Storage。
报告会扫描 User/workspaceStorage/<id>,读取其中的 workspace.json,并检查记录的本地目录或 .code-workspace 文件是否还存在。
状态说明:
Missing:记录的本地目录或 .code-workspace 文件已经不存在。
Exists:记录的本地路径仍然存在。
Unknown:该缓存目录没有可读的 workspace 目标信息。
Unsupported:目标 URI 不是本地 file: URI,因此不会检查本地路径是否存在。
你可以选择缺失项,也可以手动选择仍然有效的 workspace 缓存,然后点击 Move selected to Recycle Bin。
清理 workspaceStorage 只会移除 VS Code 的缓存状态,不会删除你的项目目录或 .code-workspace 文件。
排序和选择
- 报告默认按
Status 排序。
- 可以点击
Status、File Size、Extension Version、Workspace 等表头切换排序。
- 两个报告都会显示当前已选中的总大小。
- 详细路径和原因默认折叠;可以悬停或展开
Details 查看。
安全机制
扩展不会直接永久删除文件夹。清理操作使用 VS Code 文件服务,并启用 trash,因此选中的文件夹会移动到系统回收站。
如果当前系统或 VS Code 环境无法移动到回收站,清理会失败,并在 Extension and Workspace Cleaner 输出面板中显示错误。
设置
extensionWorkspaceCleaner.extensionDirectories:覆盖要扫描的扩展目录。
extensionWorkspaceCleaner.userDataDirectories:覆盖要扫描的 VS Code User 目录。
如果你使用自定义 --extensions-dir 或 --user-data-dir 启动 VS Code,请在设置中手动配置这些路径。
默认扫描位置
扩展会扫描常见位置,如果目录存在就纳入扫描,例如:
- Windows 扩展目录:
%USERPROFILE%\.vscode\extensions
- Windows 用户数据目录:
%APPDATA%\Code\User
- macOS 用户数据目录:
~/Library/Application Support/Code/User
- Linux 用户数据目录:
$XDG_CONFIG_HOME/Code/User 或 ~/.config/Code/User
限制
- VS Code 扩展无法可靠读取原始的
--user-data-dir 或 --extensions-dir 启动参数。如有自定义目录,需要手动配置。
- WSL、SSH、Dev Containers、Codespaces 等远程环境有独立的扩展目录和 workspaceStorage。
- Linux 的 Snap 或 Flatpak 版本可能使用非标准目录。