If you use Visual Studio Code a lot, the workspaceStorage folder can fill up with old entries. The two scripts below help you (1) list everything that’s there and (2) safely delete one workspace’s metadata by its ID.
-
Scans the standard user-data roots for VS Code / Code – Insiders / Code – OSS on Windows, macOS, and Linux.
-
Reads each
workspaceStorage/<id>/workspace.json. -
Extracts the folder URI from one of:
folderconfiguration.folderworkspace.folder
-
Prints a clean table with:
Flavor,WorkspaceID,URI,StorePath. -
Optional
--filterdoes a case-insensitive substring match on the raw URI (no decoding or normalization). -
Optional
--csv PATHwrites a CSV in UTF-8 with BOM so Excel opens it cleanly.
Intentional behavior: URIs are kept as-is (e.g.,
file:///c%3A/...). That makes filtering predictable and matches how VS Code stores keys elsewhere.
- Targets
%APPDATA%\Code\User\...(the stable “Code” flavor on Windows). - Looks up the folder URI from
workspaceStorage\<wsid>\workspace.json. - In
%APPDATA%\Code\User\globalStorage\storage.json, it removes the exact-string key fromprofileAssociations.workspacesthat matches that URI. - Backs up
storage.jsontostorage.json.bak(or.bak.N). - Deletes the directory
%APPDATA%\Code\User\workspaceStorage\<wsid>. - Supports
--dry-runto preview changes without touching files.
Note: The deletion compares strings exactly; there’s no URI → path conversion. That’s on purpose to avoid mismatches.
- Python 3.10+ (for modern type hints)
- No third-party packages; standard library only.
# Show all workspaces in a table
python list_workspaces.py
# Narrow down by raw-URI substring (case-insensitive)
python list_workspaces.py --filter "file:///c%3A/Users/me/Projects"
# Save for Excel (UTF-8 with BOM)
python list_workspaces.py --csv workspaces.csvExample table (trimmed):
+=================+=========================+==========================================+======================================+
| Flavor | WorkspaceID | URI | StorePath |
+=================+=========================+==========================================+======================================+
| Code | 1a2b3c... | file:///c%3A/Users/me/Projects/foo | C:\Users\me\AppData\Roaming\Code\...|
+=================+=========================+==========================================+======================================+
-
Find the WorkspaceID using the list script (or from the folder name under
%APPDATA%\Code\User\workspaceStorage). -
Do a dry run first:
python remove_workspace.py --wsid 1a2b3c... --dry-run- Apply if it looks right:
python remove_workspace.py --wsid 1a2b3c...You’ll see:
- Target paths (
workspace.json,storage.json) - The folder URI detected
- Whether an entry was removed from
profileAssociations.workspaces - Confirmation that
%APPDATA%\Code\User\workspaceStorage\<wsid>was deleted
- Close VS Code before running the removal script.
- Always start with
--dry-run. - A backup of
storage.jsonis created automatically. - If
storage.jsondoesn’t exist, the script simply skips that step. - If you see “
workspace.json not found”, double-check the ID or whether it belongs to another flavor (e.g., Insiders/OSS). - The Windows removal script currently touches only the stable
Codeflavor; you can adapt it to Insiders/OSS by tweaking the base path.
VS Code often stores workspace keys as percent-encoded URIs (e.g., file:///c%3A/...). By treating that string as the source of truth, the tools avoid accidental mismatches that can happen when converting URIs to local paths.
- list_workspaces.py → Cross-platform inventory with optional CSV (Excel-friendly).
- remove_workspace.py → Windows cleanup by ID with dry-run and backups.
They’re small, dependable utilities to keep your VS Code metadata tidy without guesswork.