93

Chrome's sync feature isn't picking up all of the tabs open on my Android phone.

Are the tabs stored in a file somewhere that I can access?

My intention is to export the list of tabs so that I could run a factory reset on the device.

Running Android 4.3

1
  • chrome://history/syncedTabs for anyone whose sync feature is working btw
    – Pat Myron
    Feb 1, 2023 at 20:59

12 Answers 12

58

You can use the Remote Devices feature in the Chrome debugger to connect to Chrome on the device and access the tabs. Just expand the list of tabs visible to get the full list and then highlight & copy everything shown (including the URLs) to the clipboard: https://developers.google.com/web/tools/chrome-devtools/remote-debugging/

I just managed to export ~400 tabs this way.

4
  • 4
    wanted to mention that the chrome debugger list will shorten the urls if they are too long, so instead of copy-pasting, you can get the url's directly using the method in Louis Maddox's answer
    – woojoo666
    Sep 18, 2018 at 3:29
  • @woojoo666: It looks like things in Chrome have changed and now Louis's answer also truncates the end of many URLs. Looks like any URL over 100 characters -- which in my case it about 50% of all my open tabs -- will be missing its ending.
    – peterflynn
    Sep 25, 2018 at 7:05
  • @peterflynn still works for me. Just exported a url that was 432 characters long. Just to make sure, you're opening the dev tools in a pop-out window, going to the "remote devices" pane, then using ctrl-shift-J to open a second dev-tools window, and then using the script provided here, correct?
    – woojoo666
    Sep 26, 2018 at 9:30
  • What is the minimum required Android version to do this?
    – neverMind9
    Dec 22, 2018 at 13:01
52

Update October 2022: As per Remote debug Android devices, the chrome://inspect/#devices page has replaced the Remote devices debugger panel, breaking the JS in this answer and similar ones.


Just joined this StackExchange to show some appreciation for Jeremy's answer above, and also add the few lines of JS I used to export the tabs list (since copying with the cursor isn't ideal!)

As Jeremy said, select Remote devices under More tools on Chrome devtools icon (top right of the panel):

  • set up USB debugging on your phone (under SettingsDeveloper options, root not required)
    • note that you must enable the Developer options menu, it's hidden by default to protect users
    • on my phone this required tapping multiple times on the build number under SettingsAbout Device
  • once this is done, plug your USB in and allow MTP connection
  • when the Chrome devtools remote device panel is open, the phone will then request to allow USB debugging
    • you can opt to always trust the computer

Now the device is connected,

  • open a 2nd devtools view on the devtools view from which you selected Remote devices to be able to retrieve the list of tabs using JavaScript
    • note that you must have devtools in pop-out mode (use the vertical ellipsis symbol in the top right of the panel) to be able to get this up, otherwise Command+Option+J(MAC) Ctrl+Shift+J(WINDOWS) will just close the first devtools panel.
  • expand the list from the first few items to all tabs by clicking 'Show more'
  • to script against the list, use the following few lines of code [entered in the console of the 2nd devtools window]

To export a list of all URLs open on Chrome for Android, I chose to just make the list into a markdown formatted text string and copy it to the clipboard

let bookmarkList = Array.from(document.querySelectorAll('.widget>.vbox'))
  .map(e => e.shadowRoot)
  .map(e => e && e.querySelector('.device-page-list'))
  .find(e => e);

let bookmarks = Array.from(bookmarkList.querySelectorAll('.vbox'))
  .map(e => `[${e.querySelector('.device-page-title').innerHTML}](${e.querySelector('x-link').innerHTML})`);

copy(bookmarks.join('\n'));

You will then have a list on your clipboard looking like this:

[How can I export the list of open Chrome tabs? - Android Enthusiasts Stack Exchange](https://android.stackexchange.com/questions/56635/how-can-i-export-the-list-of-open-chrome-tabs)
[Get Started with Remote Debugging Android Devices  |  Tools for Web Developers  |  Google Developers](https://developers.google.com/web/tools/chrome-devtools/remote-debugging/)
[How To Enable USB Debugging On Your Android Phone](https://www.groovypost.com/howto/mobile/how-to-enable-usb-debugging-android-phone/)
[Configure On-Device Developer Options | Android Studio](https://developer.android.com/studio/debug/dev-options.html)
...
11
  • 2
    Chrome changed, tabs = Array.from(document.querySelectorAll('div /deep/ div /deep/ div /deep/ div /deep/ div /deep/ .device-page-list .vbox'), s => ({name: s.querySelector('.device-page-title').textContent, url: s.querySelector('.devtools-link')._href})) will work now
    – dlamotte
    Jun 13, 2018 at 3:15
  • 2
    It changed again. For Chrome Version "73.0.3683.75 (Official Build) (64-bit)": tabs = Array.from(document.querySelector('div /deep/ div /deep/ div /deep/ div /deep/ div /deep/ div /deep/ div.vbox.flex-auto').shadowRoot.querySelectorAll('.devices-view .device-page-list .vbox'), s => ({name: s.querySelector('.device-page-title').textContent, url: s.querySelector('.device-page-url .devtools-link').getAttribute('href')})) (I could not access the final shadow-root via a selector, but had to use the .shadowRoot property of its host element instead. Not exactly sure why, but hey, unsupported.
    – Adrian
    Mar 25, 2019 at 21:57
  • 4
    Just in case anyone else is having trouble, I was having issues running some of these scripts (it was hammering the kernel's USB stack with 100% usage over 10+ minutes before I stopped it). The best way I found was to select the parent HTML element in the chrome dev tools inspector (use the cursor button in the top left of the nested dev tools window to select a random item in the list and then select the parent element) and then right click -> "Edit as HTML" -> copy into another text file. Then it was easier and a lot faster to adapt the above scripts to work on that local HTML copy (or BASH)
    – JZL003
    Jun 7, 2019 at 15:32
  • 6
    As of Chrome 81, "Remote Devices" is accessible from chrome://inspect/#devices instead of in Dev Tools. That makes it a bit easier, no need to open Dev-Tools-on-Dev-Tools.
    – Ben J
    May 15, 2020 at 4:57
  • 8
    To get the full names/URLs, not truncated to 100 chars (as in @priorincantatio's answer): Open Dev Tools on that Remote Devices page and edit the "inspect.js" source file in browser to remove the truncation code (currently it's text = text.substring(0, 100) + '\u2026';), save it, then [re]connect the device to [re]load the URLs. Then copy the URLs list to your clipboard using the latest valid code snippet (currently it's in the Gist above).
    – Ben J
    May 15, 2020 at 5:35
43

tl;dr:

  • have the Android command line tools installed on a development machine, and USB debugging enabled on your device. The device does not need to be rooted
  • adb forward tcp:9222 localabstract:chrome_devtools_remote
  • wget -O tabs.json http://localhost:9222/json/list

Details:

If you have the Android command line tools installed on a development machine, and have enabled USB debugging on your Android device, then you can do the following:

  • Execute adb forward tcp:9222 localabstract:chrome_devtools_remote on your development machine.

    Chrome instances expose access to a debugging protocol via a unix domain socket with the abstract address "chrome_devtools_remote". The above adb command forwards requests made to port 9222 on your development machine, onwards to that unix domain socket. (You can get a list of all the unix domain sockets on the Android device by typing adb shell cat /proc/net/unix.)

    Using this, we can run wget or curl (or indeed, a browser) and retrieve information from the mobile device's chrome instance.

  • Debugging information is provided as JSON data over HTTP. A JSON file listing the open tabs can be got by executing wget -O tabs.json http://localhost:9222/json/list.

    (Other endpoints of the API can be found at https://github.com/buggerjs/bugger-daemon/blob/master/README.md#api.)

See here for more details on enabling USB debugging, and here for an overview of how it works.

9
  • 4
    +1 as I find this answer more useful than the hack of executing javascript code to retrieve the list.
    – Zskdan
    Aug 28, 2020 at 23:23
  • 5
    THIS is the way. Be sure to have Chrome actually open on your device and displaying (i.e. don't let the screen go to sleep)
    – Jeff Trull
    Apr 17, 2021 at 0:51
  • 1
    I've created a automated php script to take on this task. It saves the json for further processing and a markdown list of links to view. Find it at github.com/machinateur/android-chrome-tab-transfer. It saved me from copying about 450 tabs to my new phone. Nov 11, 2021 at 0:19
  • 3
    For windows I downloaded the SDK (developer.android.com/studio/releases/platform-tools), extracted the zip from the download, the cd into the dir and used the adb.exe. Had to turn my device to MIDI and then press ok on the allow dialogue on my phone. Then ran the above commands in PowerShell and got the tabs file. Dec 12, 2021 at 0:36
  • 2
    Once I got adb setup this worked a lot better than getting it from the devtools with the added truncated URLs issue. It did take some effort getting a new setup on Windows trying the command line tools only rather than installing the full Android Studio.
    – Kioshiki
    Feb 18, 2022 at 22:48
15

I came across this solution when I was looking to recover tabs that had been permanently closed after my browser crashed one day. In order to access the information you require, your device needs to be rooted so you can run a file explorer app with access to the root files installed on your device. ES File Explorer or Root Explorer are my recommendations.

  1. Navigate to the root folder of your device (the protected system partition) → select DATA → select com.android.chrome.

  2. There are several places where you may find information about your current tabs.

    1. The first folder to check is app_tabs, then 0. In this folder there should be a file called tab_state which contains a list of all your current tabs.
    2. There are also other files in this folder called tab3, tab4, etc. that contain info about current tabs.
    3. IMO, you need a special "text editor / sql editor" to read the content of some of these files as the encoding is different.
  3. Next place to look is /data/com.android.chrome/app_chrome/Default/. In this folder you'll find a file called History. Depending on your situation, you may find a good list of recent site visits here.

  4. Finally, navigate to the Sync Data folder. In here, you will find the information that's being synced to Google (and this should include all the tabs you currently have synced on other devices).

    • In the file SyncData.sqlite3, you'll also find a history of all your Google searches (which I sometimes find to be an interesting read).
    • You'll need an Sqlite3 data browser program on your PC in order to read this file. The app should be able to export to a highly usable .CSV or .XLS file that you can open in MS Excel.

This could be helpful to someone I assume.

1
4

The most recent answer by simonsan is not working on my current Chrome build 75.0.3770.100. I don't have the vbox class that is used in every script posted, so I managed to write a code that is working now:

tabs = document.querySelectorAll('#devices div /deep/ div /deep/ div /deep/ div /deep/ .row')
str = '';
for (i=0;i<tabs.length;i++){
  if (tabs[i].querySelector('.name').innerText != null){
    str += '- ['+tabs[i].querySelector('.name').innerText + '] (' + tabs[i].querySelector('.url').innerText +  ')\n'
  } else {
    console.log(tabs[i])
  }
}

I've found Louis Maddox's post and screenshots very useful to decipher his script so here is mine with the updated tree.

screenshot


Anyway the solutions proposed to overcome the 100 char cap didn't work for me therefore I decided to edit the inspect.js from the source following these steps:

  1. Download the chrome-pak-customizer and unzip it.
  2. From C:\Program Files (x86)\Google\Chrome\Application\75.0.3770.100 (where 75.0.3770.100 is the name of the build) make a copy of the resources.pak in your Documents folder, drag the copy and drop it on the unpack.bat in the unzipped folder.
  3. In \document\resources_unpaked\ take the 11208.js and open it.
  4. On the line 537 or by looking for 100 there are these lines
  let text = value ? String(value) : '';
  if (text.length > 100) {
    text = text.substring(0, 100) + '\u2026';
  }

changing the 100 to 300 should be enough, it may cuts some google search links but mine where still working.
  1. Save the file and in the same folder drag the pak_index.ini and drop it on the pak.bat. now the resource.pak in \documents\ has been updated with the changes.
  2. Make a backup of resource.pak because you never know, close Chrome and replace the orginal with the updated version.

Now the script will show up to 300 chars for the urls.

6
  • 1
    Really nice! How did you find out that was the file 11208.js that you should edit? I am using another version of chrome and I dont have this file...
    – juanora
    Apr 14, 2020 at 14:41
  • 2
    I figured an easier way: just to edit the inspect.js direct on chrome.
    – juanora
    Apr 14, 2020 at 14:55
  • @juanora: how did you manage to edit it directly from chrome? Btw I don't remember but I guess I've setup the file research to look for "100" inside the files, a this point few file should popup Apr 17, 2020 at 10:28
  • thanks for you answer. I tried searching for 100, substring, etc... No success... Please check this to see how to change it directly: stackoverflow.com/a/5506786/3375218
    – juanora
    Apr 18, 2020 at 18:41
  • Thanks! Ok I'm sorry I don't know what was I as thinking: look for this '\u2026' Apr 19, 2020 at 19:15
3

This workaround will give you a text file with individual URLs for all tabs you have open in Chrome for Android.

  1. As mentioned in this answer by Michael, you have to grab the file that contains the current tabs. Using a root explorer on the device, grab this file and move it to your choice of folder in windows: /data/data/com.android.chrome/app_tabs/0/tab_state

  2. Install GNU Tools for Windows

  3. Sometimes there's a weird arrow-character in the file that screws up the script. If you run the script and it truncates part of the file, look at the last character and it'll probably be that weird arrow character. Find/replace it in the original file. Once it's gone, the script will run fine. It looks like this: -->

  4. Go to command line prompt (go to "Run" or Win+R, and type cmd) and navigate to the folder which contains sed.exe (wherever you installed it in step 2.)

  5. You'll probably want to move the original file (tab_state) to the same folder containing sed.exe. It'll make everything easier. Once you've done that, run this script:

    sed -i "s/.\{6\}http/\r\n\r\nhttp/g" tab_state
    
  6. This will modify the file with all of the URLs formatted correctly. Open the file as a text file and then copy and paste the contents into a Word document or some other location. For some reason, if you don't copy and paste the data out, when you save the file it erases all of the line breaks/carriage returns. If things screw up, just start over and do it again. When it's all said and done, you should have a file that contains a list of links to all the tabs you had open before.

3

You need to be root or Chrome to read /data/data/com.android.chrome/app_tabs/0/tab_state0

You can use this dirtycow exploit on vulnerable devices to become Chrome and get tab_state0 from an attached device:

make root
adb shell
run-as com.android.chrome
chmod 711 /data/data/com.android.chrome/app_tabs/0
chmod 644 /data/data/com.android.chrome/app_tabs/0/tab_state0
exit
cp /data/data/com.android.chrome/app_tabs/0/tab_state0 /sdcard/
exit
adb pull /sdcard/tab_state0

Once you have access to tab_state0, extract the URLs:

LC_ALL=C grep -a -o 'http[[:print:]]*' tab_state0
3

Instructions for Brave! You can replace the code in the console from Louis Maddox with this one, this is working as of today Brave Version 1.0.0 Chromium: 78.0.3904.97 (Official Build) (64-bit). Remark: You can open a new console window of the remote devices window if you activate the remote device window and press Ctrl+Shift+J

tabs = Array.from(document.querySelector('div /deep/ div /deep/ div /deep/ div /deep/ div /deep/ div /deep/ div.vbox.flex-auto').shadowRoot.querySelectorAll('.devices-view .device-page-list .vbox'), s => ({name: s.querySelector('.device-page-title').textContent, url: s.querySelector('.device-page-url .devtools-link').getAttribute('href')}))

str = ' ';

tabs.forEach(e => {
    str += '- ['+ e.name + '](' + e.url +')\n';
})
copy(str)

Then you can paste all your tabs in a textfile.

If you want to open all the tabs on your actual device replace the tabs.forEach-part with

tabs.forEach(e => {
    window.open(e.url, '_blank');
})

Don't try that with too many open tabs on your device, though.

I added this after the tabs part to manually synchronize opened tabs (brave still missing this feature and I had 650 opened tabs on my mobile device) in charges of 50 tabs:

i=0;
j=0;
tabs.forEach(e => {
  if(i<50){
    i++;
    window.open(e.url, '_blank');
  }
  j++;
})
console.log("Tabs overall:"+j);

This will open a batch of 50 tabs from your device into the opened browser window. It also shows the overall tab count. Don't close the remaining 'empty'-tab for those developer tools and the remote device though, if you want to open another batch. With Ctrl + TAB you switch through the tabs, Ctrl +D to bookmark them and Ctrl+W to close active tab. That's the way I did it manually, feel free to propose changes to this code for making everyones life's easier.

1
  • Thanks for this! -- your code above didn't work as of ``` Version 1.26.67 Chromium: 91.0.4472.114 (Official Build) (64-bit) ``` BUT, still gave me hope that Brave would work. Got it working, and posting my code below... Ok don't have the REP for it, but here is [the console .js code ](jsfiddle.net/rhfbkonv) for Brave on Android 11 as of 2021-June
    – m1m1k
    Jun 26, 2021 at 21:52
2

Michael identified the tab_state file, it remains to decode it. The following script worked for me (in kitkat KSH_VERSION='@(#)MIRBSD KSH R43 2013/02/19' or xenial BASH_VERSION='4.3.46(1)-release' on a tab_state file from Chrome 49.0.2623.105), it prints out the last URL first, between the URLs it removes any unprintable byte and all following bytes, and more if needed so at least 2 bytes are removed. Following each URL it prints a space, then the removed contiguous printable bytes if any, then a comma, then the number of other bytes removed (&said bytes within parentheses). To print the URLs only use the commented echo command instead.

tab_state=/data/data/com.android.chrome/app_tabs/0/tab_state
[[ $KSH_VERSION ]]||shopt -s extglob       #set if bash
(cat $tab_state;echo)|while read -r r;do b=
   while
      q=${r%http?(s)://*}          #chip off a URL
      [[ $q = *url= ]]&&{
         p=${r%http?(s)://*url=*}  #special case URL within URL
         [[ $p = "$r" ]]||q=$p;}
      h=${r:${#q}}                 #the chip
      h=${h%%[! -~]*}              #remove unprintable&following bytes
      u=$((${#r}-${#q}-${#h}))     #no of said bytes removed
      p=$((u<b?b-u:0))             #no of more bytes to remove
      [[ $h ]];do
         echo "${h::${#h}-p} ${h:${#h}-p},$u(${r:${#r}-u})"
      #  echo "${h::${#h}-p}"
         r=$q b=2
   done
done
1

In windows, to extract tab_state0 from a TitaniumBackup archive (that works over rooted phones)

7z e TitaniumB\com.android.chrome-20180918-001302.tar.gz -so | 7z e -si -ttar tab_state0 -r

To get the list of tabs from tab_state0

sed -b "s/^.\{20\}//g" tab_state0 | sed -b "s/.\{6\}http/\nhttp/g" > my-tabs.md

On windows I would install https://scoop.sh/ then scoop install busybox 7zip

0

You can now bulk-save all open tabs as bookmarks, which sync way easier and allow other export means directly on a PC'S Chrome:

  • Open Chrome on Android.
  • To the right of the address bar, tap Switch tabs.
  • Touch and hold any tab, or tap More and then Select tabs.
  • Choose the tabs you want to bookmark.
  • Tap More and then Bookmark tabs.

https://support.google.com/chrome/answer/2391819?co=GENIE.Platform%3DAndroid&oco=1#zippy=%2Cbookmark-tabs

2
  • That just bookmarks them. It does not finish it off with hoe to export them. Its best to make the answer complete. Jul 12, 2023 at 22:27
  • Just a note that steps 3 and later won't work if Chrome's Accessibility setting "Simplified view for open tabs" is enabled.
    – Andrew T.
    Jul 13, 2023 at 2:56
0

Pitching in here that for those which run android with root, it is possible to export all of the chrome bookmarks via adb:

# adb shell "su - -c cat /data/data/com.android.chrome/app_chrome/Default/Bookmarks"

The bookmarks file is in plaintext JSON format, but is permissions protected by app userid, therefore root is required to read it.

it is handy if you do not sync chrome profiles across devices \ use google login with chrome.

the location is pretty standard to all androids, the Default should be recognizable to those who tinkered with it in the past.. it has the encrypted* sqlite sessions and cookies stores.

in windows it's encrypted via DPAPI, but I have no idea about android..

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .