Recovering Firefox Tabs

My open Tabs in Firefox disappeared. I restored them through the sessionstore backups in the profile folder.

I have a lot of open Firefox tabs. That is despite efforts to reduce them; having lost hundres of them once, saving many as bookmarks, and using the Tab Stash addon to stash some into categories. Discovering interesting pages to read later, come back to later, use as inspiration or potential tools or information, and current work that may or may not be finished or put on hold. They accumulate.

I have the “Open previous windows and tabs” enabled, so I can always come back to my previous session of open tabs. Quite useful, firstly to not have to always bookmark or stash interesting links into categories or a generic backlog (maybe I should), and secondly for open tabs of “current” projects and things.

Yesterday I opened a private window, and accidentally closed the main window. Which should not be a problem, because you can usually always use History -> Recently Closed Windows to open it again. But this time it did not work, it was not there (maybe because the other was a private window, or because I first opened a new normal window to see if they are still there?).

Firefox runtime, application data is stored in the %APPDATA%\Mozilla\Firefox folder.

Firefox uses profiles. Either transparently, invisible to you, with a single profile, or you can make use of profiles to have separate, isolated profiles (of settings, addons, tabs, bookmarks, history, cookies, sessions, …).

The profiles are stored under %APPDATA%\Mozilla\Firefox\Profiles. The profiles.ini file serves as a description and definition of the available and used profiles.

By disabling StartWithLastProfile in the General section by setting it to 0, you are able to choose profiles, and also see (preselected), the profile your Firefox starts with automatically if you usually start it without a choice, but have multiple profiles.

In the Profiles subfolder, you will find the profiles, as defined in profiles.ini.

When your Firefox is not running, a file called sessionstore.jsonlz4 holds all the session information, including open tabs.

The folder sessionstore-backups holds backup files of this file.

  • recovery.jsonlz4 and recovery.baklz4 for the current/last session
  • previous.jsonlz4 for the previous session
  • upgrade.jsonlz4-YYYYMMDDHHMMSS presumably backups on Firefox updates

Luckily, Firefox installed an update yesterday, so I had a very recent backup despite starting Firefox multiple times effectively overwriting and losing the previous session backup file.

Restoring the backup is as easy as, when Firefox is not running, renaming the file to and overwriting the sessionstore.jsonlz4 file.

When starting Firefox, the session should be restored as before.

The jsonlz4 file format is a custom format. The data is LZ4 compressed, and a short file header is prepended.

I created a tool that converts jsonlz4 files to json files.

The session store mainly contains windows, tabs, cookies.