Recover Unsaved Sublime Text Files
Sublime Text autosaves your session (including unsaved tabs) every few seconds, so a crash rarely loses your work. Reopening Sublime usually restores everything. If it doesn't, your text is inside Session.sublime_session. Steps below.
First: just reopen Sublime
Sublime restores open tabs and unsaved buffers on launch. If your text doesn't come back, close Sublime again before anything overwrites the session, then go to the session file.
Find the session file
- Windows:
%APPDATA%\Sublime Text\Local\Session.sublime_session(older builds:Sublime Text 3\Local\) - macOS:
~/Library/Application Support/Sublime Text/Local/ - Linux:
~/.config/sublime-text/Local/
Pull your text out of the session, step by step
- Copy the file first. Make a duplicate of
Session.sublime_sessionsomewhere safe before you touch it, so a mistake can't cost you the recovery. - Open the copy in another editor (Notepad, VS Code, nano) — never the same Sublime instance you are recovering from, or it may overwrite the session on exit.
- Search for
"buffers". It's a JSON array; each unsaved tab is one object. Your text lives under the"contents"key of each buffer. - Decode the escapes. The stored text is a JSON string: line breaks appear as
\n, tabs as\t, quotes as\", and non-ASCII as\uXXXX. Paste it into a new file and replace\nwith real newlines (most editors do this with a regex find/replace, e.g. search\nwith "regex" off and type a literal newline). - Save it as a real file with the correct extension immediately, then verify it opens cleanly.
If "buffers" is empty or there is no contents
Some builds split state across files. In the same Local/ folder check Auto Save Session.sublime_session (written roughly every 30 seconds) — it often holds newer buffer contents than the main session. If both look empty, search the whole folder for a recent fragment: on macOS/Linux grep -ril "a phrase you typed" ~/.config/sublime-text/, on Windows use File Explorer content search.
If the session is corrupted
- Look for
Session.sublime_session-backupin the same folder — Sublime keeps a backup against corruption. - Copy recovered text into a new file and save it properly.
Stop losing work next time
Keep hot_exit enabled (default) so unsaved buffers survive a close. For crash resistance add to Preferences → Settings: "auto_save": true (Sublime 4) and "save_on_focus_lost": true so named files flush to disk whenever you switch away. These don't help unnamed scratch tabs — give anything you care about a filename early.
FAQ
Where does Sublime Text keep unsaved files after a crash?
In Session.sublime_session. On Windows that's %APPDATA%\Sublime Text\Local\, on macOS ~/Library/Application Support/Sublime Text/Local/, on Linux ~/.config/sublime-text/Local/. It's a JSON file — your unsaved text is under the 'buffers' → 'contents' keys.
Sublime didn't restore my tabs — can I still get my work?
Yes. Close Sublime so nothing overwrites the session, then open Session.sublime_session in another editor and search for 'contents' to find and copy your unsaved text. If it's corrupted, try Session.sublime_session-backup in the same folder.
Does Sublime autosave unsaved files automatically?
Yes — it writes session state (including unsaved buffers) every ~30 seconds and uses hot_exit to keep them between launches, so a crash usually loses only the last few seconds.
How do I open the .sublime_session file?
It's plain JSON text — open it in any text editor (even Notepad). Don't open it in the same Sublime instance you're recovering, or you risk overwriting it; use a different editor.
My unsaved text has \n everywhere after I copied it — how do I fix the line breaks?
That is JSON escaping. In your editor do a find/replace: search for the two characters backslash-n and replace with a real newline (in VS Code enable regex and use \n in the replace box, or in Sublime use \n with regex on). Also convert \t to tab and \" to a plain quote.
Is there a second session file if the main one is empty?
Yes — look for Auto Save Session.sublime_session in the same Local/ folder. Sublime writes it on a short interval, so it sometimes contains newer unsaved content than the main Session.sublime_session.
How do I stop Sublime from losing unsaved work after a crash?
Leave hot_exit on (it is by default), and add "auto_save": true and "save_on_focus_lost": true to your user settings. Named files then flush to disk automatically; give scratch buffers a filename early so they are covered too.
Other file types explained
- What Is a .idlk File? (InDesign Lock File — Safe to Delete)
- Download Stuck at 100% But Not Finishing — How to Fix It
- Microsoft Edge Download Stuck or Not Finishing — How to Fix It
- Recover an Unsaved File in VS Code After Closing or a Crash
- What Is a .!UT File?
- .asd vs .wbk — Word AutoRecover or Backup?
- .bak vs .old — Which Backup Should You Keep?
- .crdownload vs .opdownload — What's the Difference?