Recover Unsaved VS Code Files
VS Code keeps unsaved edits in a hidden Backups folder, so a closed tab or a crash usually hasn't lost your work. First try reopening VS Code — it restores the last session automatically. If not, the raw text is in %appdata%\Code\Backups. Steps below.
First: reopen VS Code
VS Code restores your previous session by default — unsaved tabs reappear with their content. If they don't, don't open or edit anything yet; go straight to the backup folder.
Find the backup files
- Windows:
%appdata%\Code\Backups - macOS:
~/Library/Application Support/Code/Backups - Linux:
~/.config/Code/Backups
Inside Backups you'll find folders named with a hash per workspace. Open workspaces.json in that folder to match a hash to your project path. The backup files inside hold your unsaved text as plain content — open them in any editor and copy it out.
Restore cleanly
- Copy the recovered text into a new file and save it under a real name before editing further.
- If you use the Insiders build, the path is
Code - Insidersinstead ofCode. - Enable Hot Exit (Settings → search
files.hotExit, set toonExitAndWindowClose) so VS Code always keeps unsaved state next time.
FAQ
Where does VS Code store unsaved files?
In a hidden Backups folder: %appdata%\Code\Backups on Windows, ~/Library/Application Support/Code/Backups on macOS, or ~/.config/Code/Backups on Linux. Each workspace gets a hashed subfolder holding the raw unsaved text.
I closed VS Code without saving — is my work gone?
Usually not. Reopen VS Code; it restores the last session with unsaved tabs. If that fails, open the Backups folder above and copy your text out of the backup file before doing anything else.
How do I match a backup folder to my project?
Open workspaces.json inside the Backups folder — it lists each workspace's directory path next to its hash, so you can find the subfolder that belongs to your project.
How do I stop losing unsaved VS Code work in future?
Enable Hot Exit: open Settings, search files.hotExit, and set it to onExitAndWindowClose. VS Code will then always preserve unsaved editors when you close it.
Other file types explained
- What Is a File Ending in ~ (Tilde)? Editor Backup File
- Recover an Unsaved Notepad++ File After a Crash
- Vim: Swap File Already Exists — Recover, Edit, or Delete?
- Convert .crdownload to MP4 — How to Play an Incomplete Video
- What Is a .LOG File?
- What Is a .OLD File?
- What Is an .OPDOWNLOAD File? (Opera unfinished download)
- What Is a .PNF File? (Windows precompiled INF)