Android - How can I export all my open Firefox Tabs to a text file?

On Android system you can use Termux (No root required):

  1. Navigate in Firefox to URL: file:///data/data/org.mozilla.firefox/files/mozilla/
  2. Choose the link of ***.default folder of your profile
  3. Choose the sessionstore.js file
  4. Copy content of this file and save it in sessionstore.js file on local storage
  5. Run the command in Termux to output your tabs urls:

    cat ~/storage/shared/sessionstore.js | sed -n 's@{\"url\":\"@&\n@g; s@\",\"title\"@\n@gp' | sed '/^[:{]\"/d'
    

    Or, this command to save your tabs urls in file sessionstore.txt on your local storage:

    cat ~/storage/shared/sessionstore.js | sed -n 's@{\"url\":\"@&\n@g; s@\",\"title\"@\n@gp' | sed '/^[:{]\"/d' > ~/storage/shared/sessionstore.txt
    

Note: this solution requires a rooted Android.

In a terminal emulator app, execute:

(Requires Busybox if running Android 5.1.1 or below. For Marshmallow, remove the term busybox from the following command.)

su
content query --uri content://org.mozilla.firefox.db.tabs/tabs/ --projection url | busybox cut -d '=' f 2 > /sdcard/firefox_tabs.txt

Explanation of the second command:

  • content query: to query a Content Provider
  • org.mozilla.firefox.db.tabs: a content provider from Firefox.
  • --projection url: list data from the url column only

(Click image to enlarge)

IMG:

Or if you have the sqlite3 tool in Android, then you can do:

su
sqlite3 /data/data/org.mozilla.firefox/files/mozilla/*.default/browser.db "SELECT url FROM tabs ORDER BY position" > /sdcard/firefox_tabs.txt 

I've assumed that you have a single Firefox profile and its name has not been altered. If you've a multi-profile setup or if you did change the profile's name, then instead of *.default provide the correct name of the profile of whose tabs you want in your list.


Apparently there is an Android specific Firefox browser plug-in called Tabs Backup. This seem to work like charm! It places a text file in /storage/emulated/0/Android/tabs_backup/ (Aka. /sdcard/Android/tabs_backup/) called backup_DDMMYYY_hhmmss.txt.

However, it would still be interesting to know how to do this from command line.


UPDATE: 2018-08-15

Since some time back, Tabs Backup no longer works for the recent versions of Android Firefox. Instead, use Tabs Export. You also need a separate plugin, to import Tabs.