What if Firefox loses your tabs ?

Submitted by dag on Fri, 2011/05/20 - 17:17

It happened to me today, not sure if it was because I closed my main window and firefox had some other window in the back ? But the next run all my tabs were gone, and they were nowhere to be found in my 'Recently Closed Tabs' list. My sessionstore.js was huge, but re-opening Firefox only brought up the default homepage.

If this happens to you on re-opening Firefox, don't blink a second, make a copy of your sessionstore.bak and sessionstore.js so that Firefox doesn't replace them and you lose everything.

In my case re-opening didn't really make any difference, all tabs were still in the sessionstore.js, even though I couldn't get to them properly from within Firefox. Even my pinned tabs were missing.

Some websites provide tools (in perl or python) to recover all URLs from your sessionstore.js, but that included a lot more than what was open, so many that Firefox would start swapping and the machine died on me. So no luck there.

The sessionstore.js is in fact one big JSON file. But it is unusable as everything is on a single line. No luck using an editor on that file like this. So the first thing was to look for something to make the information readable. There is a JSONview add-on for Firefox, but before complicating my problem with new tools I wanted to look at it using VIM.

On my RHEL 6.1 desktop I had two JSON commands: json_verify and json_reformat. My first thought was the sessionstore.js was somehow corrupt, but json_verify did not agree with me. Sending my sessionstore.js to json_reformat

# cat sessionstore.bak.copy | json_reformat >sessionstore.js

provided me with human-parseable output. By looking at the file, it was obvious that the sessions I wanted were considered Closed Tabs and there was only one Tab active.

By deleting the active session(s) and deleting the start of the _ClosedTabs structure, so that all my sessions are inside the tabs structure, you can restore those _ClosedTabs with the least amount of effort (so simply deleting the right lines so the structures parse fine in the right section)

Hope this is of use to you one day too !

I had this too, today,

I had this too, today, firefox crashed, I opened it again, but it just opened the default page. I started extracting URLs from the sessionstore.js files, too, but then managed to get my tabs back by remembering to surf to "about:sessionrestore" ... :)

Yes, I didn't describe that

Yes, I didn't describe that as it failed to work on my system. But I guess I should have mentioned it for people to try first.

By deleting the active

By deleting the active session(s) and deleting the start of the _ClosedTabs structure, so that all my sessions are inside the tabs structure, you can restore those _ClosedTabs with the least amount of effort (so simply deleting the right lines so the structures parse fine in the right section)

Great posting. The problem for an amateur like me is the lack of concrete examples. Could I trouble you for one or two instances of what code to delete?


I had the same problem today, except my session was considered a closed window in the sessionstore file.

about:sessionrestore didn't work for me but thanks to your guide I was able to quickly fix the problem in notepad and my 100+ tabs were back.


After opening the

After opening the sessionStore.bak file I found that all the tabs were not being restore because they had been moved to the '_closedWindows' section. So I opened the file in an online json editor, copied the the 'tabs' section(including the header) under '_closedWindows' to 'Windows' where it should have been, deleted the original and everything is running smoothly again. Hope this helps someone else in the same desesperate situation.

I don't understand what

I don't understand what you're talking about... How do you use Json and VIM programs to solve the problem. Can you please be more specific? I recently lost all my tabs and opened sessionstore.js in firefox and tried to gather each tab one by one from that very long line. A very insufficient method yes, but it was only because I did not understand a single thing you wrote past the forth-fifth paragraph. I think I managed to pick most of the tabs up, but I really want to understand what the hell you're talking about. Do you expect people to have a little background with these programs to understand your input? Would really appreciate if you can clear up your solution to this problem so us real noobs understands at least vaguely what you're trying to say. Thank you.

You did it!

Onze every year I'm loosing my tabs. This time because of a FF crash. Why the FF team did not already supply a solution ( any ) for these kinds of situations is beyond me. But you did solve it for me today. Thanks!

This keeps happening to me.

This keeps happening to me. Your guide is the only thing that I have found that has allowed me to recover all my tabs (much thanks for that!) I have no idea what causes this bug exactly but it seems to occur whenever an automatic update to NoScript is applied, even though the changelog says it should be fixed since

How to extract nested (incl. closed) about:sessionrestore pages

I had a similar problem, but Firefox would not load the old tabs into about:sessionrestore even after moving them from _closedTabs to tabs (and adjusting the structure to eliminate the extra 'entries' dict in _closedTabs). Instead I used this Python script to extract the contents of the about:sessionrestore page that had been closed. After running the script you need to copy the resulting sessionstore.0, for example, to sessionstore.js (in general there may be more than one recovered session and you'll have to choose the right one). I recommend also installing SessionSaver, since it loses sessions less often than the built-in saver.

Note that this has only been tested with Firefox 10.0a2. It depends on the sessionstore files being valid JSON; I'm not sure which version that happened in. First install simplejson if it's not already installed.

Can someone explain this very useful knowledge in layman English

Please can some take time to explain the procedures in layman English. Many of us have encountered this problem. If some one can list all the step/s clearly it would help. Please!

I don't know if people

I don't know if people understood all this. Here is a short story and a simple way.
First, make sure Firefox is closed, after you replaced "sessionstore.js" with you big "sessionstore.bak" edit "sessionstore.js" and if you see this line at the beginning:
Save it and you are good to go :)


You did it, great job!
With your help I restored far more than 100 tabs :)
For those of you having problems in understanding how to solve the problem, maybe this makes it clear:
You have to open the sessionrestore.js with a text editor (notepad), and then in the first line there should be written: {"windows":[{"tabs
Now you have to delete all the text from this point (beginning with ") until that point at the next occurence of the phrase: _closedTabs (ending with ")
You have to take care, that you don't destroy the syntax, take care of the special characters, the beginning should look somehow like this:


Then save the text file and restart firefox. If it didn't help, you have to repeat all the steps, as there is normally more than one section in the file beginning with "_closedTabs", so you may have to try to find the right section, the one that contains your tabs.

Great guide! With

Great guide!

With json_reformat I was able to detect the error in the structure: I just needed to switch "_closedWindow" with "window".

Thanks a lot, without my session I'm pretty lost on the internet :)

json_reformat did the trick

Great guide!

With json_reformat I was able to detect the error in the structure: I just needed to switch "_closedWindow" with "window".

Thanks a lot, without my session I'm pretty lost on the internet :)

Thanks for help

I had this exact problem and I feel so relieved having stumbled upon your post!

I used jsoneditoronline.org to restructure the sessionstore.js file. It's a nice intuitive JSON editor, where I can just drag and drop sections inside a file (in my case it was from _ClosedWindows to windows).

Everything is back to normal now tab-whoring as usual! :)
Thanks ever so much, dag!

Scipt for fixing sessionstore.js

I recently had this issue, and I started dissecting my sessionstore.js file, instead of using Python I used PHP to create a tool that helps you (from a command line interface) to dump/edit/clean and unclose windows in your sessionstore.js file

Further details in my blog post:

The script is of course OpenSource! :)

Here's how I fixed it: 1.

Here's how I fixed it:

1. Close firefox. Before you do, open profile folder by clicking Help > Troubleshooting Information, then Show Folder.

2. Backup sessionstore.js and sessionstore.bak.

3. Open sessionstore.js, you should see {"Windows": at the beginning.

4. Delete everything from : to "_closedWindows" (search for it)

5. Save.

6. Open firefox. Treat yourself to a beer.

Thanks to dag's post, I used notepad++ with jsmin plugin to study json file.

This article just helped me save a session with +1000 tabs!

I was about to freak out this morning after a Firefox crash cost me +1000 tabs (yes, more than a thousand... I kinda get carried away when doing research)
I'd like to share the tools I used to solve this:
(hope this doesn't get flagged as spam)

JSON Editors
Web: http://www.jsoneditoronline.org/
App: http://tomeko.net/software/JSONedit/index.php?lang=en

Plugin to prevent a similar loss in the future:

Hope this helps someone else as it did to me.

From few days am getting

From few days am getting problem to new tabs , the Firefox get hang for few minutes and the new tabs open in new window. What might be the reason for this. Any help?

I got the same problem, but no longer exists alternative used Go

I got the same problem, but no longer exists alternative used Google chrome

Great finding. Well - this

Great finding. Well - this was the first time i experienced such a behavior. Yesterday resp today morning i closed the broswer without any problems and as i started it today - without any warnings - i just saw a few tabs. To be clearly i had ~50 Tabs total in different groups and all these groups are still there but just 3 of them contain any tabs - #1 group has all 4 entries, #2 is ~ half complete, and the supposed to be biggest one #3 just got 2 tabs. The other 3 groups are as i wrote empty. Can't be date too - the tabs in groups #1&2 are at least few days old, only the 2 tabs in #3 have been used yesterday/last session.

So i took a look into sessionstore.bak (also made copys btw) and found it has (beside timestamp) same data. Then i tried to search with recuva on some recovery files but as expected on ssd with trim - no use. Then i searched and found this site. On the unsorted JSON finding the "_ClosedTabs" and "_ClosedWindows" isn't that easy so i tried to find an JSON editor. I don't like online tools - especially when handling browser/session data. I found some like "xmlmarker_2_2" "XML-ValidatorBuddy 4.4" (btw. dont try JsonEditor_v1.1 using fiddler4 - ist just for traffic capturing) but they were all of no use. "eclipse + jsonedit plugin" might be a good tipp, but some might don't want to install such tools and i couldn't manage to get it working (appeared on the "perferences" but no "json view" and no "open with").

So what i found working and doing the job i need was a file called "jsoneditor-2.2.1.zip" with included 03-Example. So i managed to get a more structured code and could move the tabs etc. I also saw that there still aren't all links included - only ~half of them, yet i wanted to test it. It did open the amount of tabs that where set, but no links (except for above tabs) while i know they are included in the session. After some tries i decided to test "David-Sarah Hopwood"'s Python method. First: simplejson was bit picky - it's already included in Python 2.6+ but as json. "import json as simplejson" gives no warning but doesn't work either. So i just renamed it in the script. Finally things started and peng: "TypeError: unsupported operand type(s) for >>: 'builtin_function_or_method' and '_io.TextIOWrapper'" This is where i give up. So anyone an idea what i could do next? Any way to repar the json or should i just copy the links out and start from scratch?

Further any tipps for session backups? I already use sync, but for AddOns, Passwords, Bookmarks only as i use different profiles, machines, .... with different sessions i don't need to mix up.

You can use the utility at

You can use the utility at http://firefox-session-restore.herokuapp.com/ to restore your tabs. Just paste in the contents of sessionstore.bak.

This happened to me when

This happened to me when writing text accidentaly pressed Ctr+Shift+w instead of Ctrl+W to enter capital letter.

Thanks to all comments it was easy fix.

1. Open sessionstore.js, you should see {"Windows": at the beginning.

2. Delete everything from : to "_closedWindows" (search for it) including "_closedWindows".