You closed Visual Studio Code, declined to save, or the editor shut down during a crash, and now an untitled document you spent an hour on has vanished from the tab bar. Unlike a simple text editor, VS Code keeps careful working copies of unsaved and untitled files in a dedicated backup folder on your computer. If you know where that folder lives and how to read what is inside it, you can often get the exact text back in a few minutes.
This guide walks you through the automatic restore first, then the manual backup folder method for Windows, with the same idea explained for anyone who needs to check quickly. Go slowly, copy before you edit, and do not clear VS Code data until you have checked.
Quick Answer
Reopen VS Code first, because it normally restores unsaved and untitled files automatically through its hot exit feature. If the file does not return, open the Backups folder inside the VS Code user data folder, find the newest working folder by date, and open the backup file inside it to recover your text, then save it under a proper name straight away.
How VS Code Backups Actually Work
VS Code separates a saved file on disk from the working copy you see in the editor. When you type in an untitled file, or change a saved file without saving, VS Code writes a backup of that working copy so a crash does not wipe it out. On a normal close with hot exit enabled, it keeps that state and reopens the same windows and dirty editors next time.
Problems start when hot exit is off, when you used a different profile, or when you opened a different VS Code installation. The backup may still exist, just not in the session that loaded. That is why the manual folder check matters.
Terms that help you search the right place
- Untitled file: A new editor tab that was never saved to a path. Its only copy is the backup.
- Dirty editor: A saved file with unsaved changes. The dot on the tab means the working copy differs from disk.
- Hot exit: The VS Code feature that restores unsaved editors when you reopen the program.
- Working folder hash: Backup subfolders use coded names, so you must sort by date rather than by readable file names.
Method 1: Let VS Code Restore It Automatically
- Reopen VS Code in the same way you normally do, and open the same folder or workspace if you use one.
- Wait for all windows to load. Restored untitled editors can take a moment to appear.
- Check every tab and also use File > Reopen Closed Editor if the tab was closed very recently.
- If your text appears, press Ctrl + Shift + S for Save As, give it a clear file name and extension, and save it in your project folder.
- Save a second copy somewhere safe before you continue editing, in case the restored tab was only a partial version.
If VS Code opens clean with no restored editors, do not start writing a lot of new untitled files. Each new untitled backup adds noise to the folder you are about to search. Move directly to the manual method.
Method 2: Find the Text in the Backups Folder on Windows
This is the core recovery method. The default location on Windows is inside your roaming app data. Other systems use a similar user data path, and the official documentation explains the layout for each platform.
- Close VS Code completely after you have confirmed the automatic restore did not bring the file back. Check that no VS Code window is still open.
- Press Windows key + R, type %APPDATA%\Code\User\Backups, and press Enter.
- If that folder does not open, try %APPDATA%\Code – Insiders\User\Backups if you use the Insiders build, or check for a profile-specific Backups folder if you use VS Code profiles.
- Inside Backups you will see one or more folders with long coded names. Sort by Date modified and open the newest folder first, especially one changed at the time you lost the file.
- Inside that folder, open the untitled subfolder if present. For changes to a named file, there may also be a folder that matches the file type or working copy name.
- Copy the entire newest backup folder to your Desktop before you open anything. Always inspect copies.
- Open each file in the copied untitled folder. You can open them in Notepad for a quick read, or drag them into a fresh VS Code window. The files often have no extension, so your editor may ask how to open them. Choose text.
- When you find your document, select all the text, paste it into a new editor tab, and use Save As to store it with the correct name and extension, such as .txt, .js, .py, or .md.
- Compare the start and end of the recovered text carefully. A backup is a snapshot, so confirm the last lines you typed are present before you rely on it.
The official Visual Studio Code documentation on editing basics and backup behaviour describes hot exit and settings in detail if your menus differ. For settings names and defaults, the VS Code settings reference on the official site is the safest place to confirm what your version uses.
Method 3: Use Local History as a Second Safety Net
For files that were saved at least once, VS Code also keeps a local history timeline. This will not rescue a file that was never saved, but it is excellent for a named file whose unsaved or badly edited version needs rolling back.
- Open the folder that holds, or held, the named file.
- In the Explorer panel, find the Timeline view at the bottom.
- Look for Local History entries with times from before the close or crash.
- Click an entry to preview it, and check whether it holds the version you need.
- Restore only after you have copied the current version somewhere else, so you do not replace a newer good file with an older one by mistake.
If your lost work involves more than one program, our guide to recovering an unsaved Notepad file after a restart in Windows 11 explains the same copy-first approach for simpler editors, which is useful when a crash affected several apps at once.
Settings to Change So This Does Not Happen Again
- Open Settings with Ctrl + comma.
- Search for hot exit and set Files: Hot Exit to onExitAndWindowClose or the always option offered in your version, so unsaved editors are kept when windows close.
- Search for auto save and consider afterDelay for project work, so named files save themselves while you type.
- Search for backup and confirm no cleanup tool or setting is set to delete Backups on exit.
- Save untitled work early. Press Ctrl + S on a new tab within the first few minutes and give it a real name. It is the single habit that prevents most losses.
Common Mistakes That Make Recovery Harder
- Clearing app data or reinstalling first: A reinstall or profile reset can remove the Backups folder. Always copy Backups to the Desktop before you reinstall or reset anything.
- Opening the wrong profile or build: Stable, Insiders, and separate profiles each have their own Backups. Check the build you were actually using when the file was lost.
- Editing the original backup file: Work from a copy. If you save changes into the original backup by accident, you may overwrite the only recovered version.
- Giving up because names look coded: Backup folders use hashes, not friendly names. Date and time are your guide, not the folder title.
- Creating many new untitled tabs while searching: This buries the old backup under new ones. Pause new work until you have copied the Backups folder safely.
Conclusion
A closed unsaved document in VS Code is rarely gone the moment you close the tab. Try the automatic hot exit restore first, then go straight to the Backups folder, copy the newest dated folder to safety, and open the untitled backups until you find your text. Save the recovered work under a proper name immediately, turn on hot exit and auto save, and make early saving a habit so the next close or crash costs you nothing.
Frequently Asked Questions
Where is the VS Code backup folder on Windows?
By default it is at %APPDATA%\Code\User\Backups. Insiders uses Code – Insiders instead of Code, and custom profiles can hold their own Backups folder, so check the build and profile you were using.
Can I recover an untitled file after I closed VS Code normally?
Often yes, if hot exit was enabled, because VS Code keeps the working copy and restores it. If it did not restore, check the Backups folder manually before you create new untitled files or clear any data.
Why are the backup folder names just random letters and numbers?
VS Code names working backup folders with coded identifiers linked to the workspace and window, not with your file name. Sort by date modified and open the newest folders first to find the right snapshot quickly.
Does local history help for a file I never saved?
No. Local History tracks versions of files that exist on disk. A never-saved untitled file relies on the Backups folder and hot exit, which is why copying that folder early matters so much.
What should I do as soon as I find my text in a backup?
Stop editing the backup itself. Copy the text into a new tab, use Save As with the correct name and extension in your project folder, and save a second copy elsewhere before you continue working.


Leave a Reply