47

I have created some search entries in Google Chrome using 'Edit search engines'.

How can I share some of these entries with my colleagues?

2
  • This is such a great question. I found ludovic.chabant.com/devblog/2010/12/29/… but don't want to bother trying it since it's from 2010-2011. 5 to 6 years on the internet is an eternity. I wish there were a convenient (updated) way to share across Google accounts and across profiles within the same Chrome installation. – Ryan Jul 12 '16 at 16:03
  • Can someone create a feature request to Google so we all can upvote it there? – userJT Feb 3 '20 at 17:31

10 Answers 10

28

Edit 2020-07-27:

The export part of this solution does not work anymore in Chrome 84 (the settings object used in the script is no longer available). The import script is not very useful without the export part but it should still work for importing an existing JSON file with the settings or for transfering search engine settings from an older version of Chrome/Chromium to the current version.

Here is a simple solution to export and import Chrome search engine settings without using any external tools or editing the registry:

  1. Open the Search Engine Settings page in Chrome (chrome://settings/searchEngines).
  2. Open Chrome Developer Tools.
  • Shortcut: F12 or Ctrl+Shift+I (on Windows, shortcuts on other platforms may differ).
  • Manual navigation: Three-dot menu in upper-right corner > More Tools > Developer Tools.
  1. Click Console in the top menu bar of Chrome Developer Tools.
  2. Paste one of the following scripts into the console and press Enter.

To download a JSON file with search engine settings:

(function exportSEs() {
  /* Auxiliary function to download a file with the exported data */
  function downloadData(filename, data) {
    const file = new File([data], { type: 'text/json' });
    const elem = document.createElement('a');
    elem.href = URL.createObjectURL(file);
    elem.download = filename;
    elem.click();
  }

  /* Actual search engine export magic */
  settings.SearchEnginesBrowserProxyImpl.prototype.getSearchEnginesList()
    .then((searchEngines) => {
      downloadData('search_engines.json', JSON.stringify(searchEngines.others));
    });
}());

To import settings from a JSON file created using the script above:

(async function importSEs() {
  /* Auxiliary function to open a file selection dialog */
  function selectFileToRead() {
    return new Promise((resolve) => {
      const input = document.createElement('input');
      input.setAttribute('type', 'file');
      input.addEventListener('change', (e) => {
        resolve(e.target.files[0]);
      }, false);
      input.click();
    });
  }

  /* Auxiliary function to read data from a file */
  function readFile(file) {
    return new Promise((resolve) => {
      const reader = new FileReader();
      reader.addEventListener('load', (e) => {
        resolve(e.target.result);
      });
      reader.readAsText(file);
    });
  }

  const file = await selectFileToRead();
  const content = await readFile(file);
  const searchEngines = JSON.parse(content);
  searchEngines.forEach(({ name, keyword, url }) => {
    /* Actual search engine import magic */
    chrome.send('searchEngineEditStarted', [-1]);
    chrome.send('searchEngineEditCompleted', [name, keyword, url]);
  });
}());

Notes

  • I tested the scripts in Chrome 75.0.3770.100 on Windows 8.1.
  • The scripts export and import search enines in the Other Search Engines section only but they can easily be tweaked to include default search engines as well.
  • Do not try to distribute the scripts as bookmarklets, bookmarklets do not execute on chrome:// URLs (been there, done that).
13
  • These instructions worked perfectly well for me, chrome version 74. – Jason Aug 5 '19 at 13:52
  • 1
    I used this to transfer my Chrome search engine settings to Chromium Edge! Brilliant. – Scott Rhee Jan 8 '20 at 23:23
  • 1
    @MarcoLackovic Both scripts still work in my Chrome 83.0.4103.116 (64-bit) on Windows 8.1. Are you sure you ran the script in the console of the search engine settings page (chrome://settings/searchEngines)? The chrome.send() method is not available in the console for ordinary pages. – Petr Srníček Jun 24 '20 at 17:13
  • 3
    @OlivierCailloux Thanks for the suggestion. Unfortunately, the export script ceased to work in the latest stable version of Chrome (84). Since the script now only works in legacy versions, I don't think that extending it is worth the effort. I will update my answer if I ever find a way to support current Chrome. – Petr Srníček Jul 27 '20 at 14:46
  • 1
    @PetrSrníček I made a fairly gross DOM traversal to get the export working again for Chrome 88 superuser.com/a/1626575/55621. Feel free to improve on this and update this answer. This saved me an enormous amount of time (I use Chrome search engines as hotkeys...and tend to have 50-100 of them). – Jacob Dalton Feb 16 at 20:51
10

Here's a single command to export your chrome search engines as CSV on linux:

sqlite3 -csv ~/.config/chromium/Default/Web\ Data 'select short_name,keyword,url from keywords' > ~/search-engines.csv

You need sqlite3 installed. Replace ~/.config/chrome with the corresponding Windows path if you're on Windows. Should be something like %AppData%\Local\Google\Chrome\User Data

Exporting as SQL for re-importing elsewhere

Instead of exporting to CSV, you could export to sqlite insert statements:

(printf 'begin transaction;\n'; sqlite3 ~/.config/chromium/Default/Web\ Data 'select short_name,keyword,url,favicon_url from keywords' | awk -F\| '{ printf "insert into keywords (short_name, keyword, url, favicon_url) values ('"'"%s"'"', '"'"%s"'"', '"'"%s"'"', '"'"%s"'"');\n", $1, $2, $3, $4 }'; printf 'end transaction;\n') > ~/search-engine-export.sql

Then copy ~/search-engine-export.sql to the other machine, and import with this command:

sqlite3 ~/.config/chromium/Default/Web\ Data < search-engine-export.sql

Making sure to replace the Web Data path with the one on your machine as described above.

4
  • Worked great for me! And I'd like to give a plug for WSL on Windows 10, which essentially makes this a Windows-native solution. Would you also share the command to import? – tbc0 Sep 12 '18 at 19:11
  • 1
    @tbc0 I've added import instructions as well. I haven't tested on WSL but it should work in theory... – William Casarin Sep 13 '18 at 19:41
  • 1
    You may have to handle the ' character. You can add this in your awk function esc(s){gsub("\x27","\x27\x27",s);return s} for $1 and $2 ====> esc($1), esc($2) – Yzmir Ramirez Mar 3 '19 at 6:31
  • FWIW, for the Mac, I wanted to introspect on the values, and used the SQLIte Manager add-on to read the SQLite file at path ~/Library/Application Support/Google/Chrome/Default/Web Data. – Brett Zamir Dec 30 '20 at 14:14
6

It's possible, but it's enough of a pain that you won't want to.

  1. Find the Web Data file in your Chrome profile. In Windows 7 it will be here: "%USERPROFILE%\AppData\Local\Google\Chrome\User Data\Default\Web Data"

  2. Open the file with an SQLite program like SQLite Studio or sqlite in Ubuntu (sudo apt-get install sqlite) and export the keywords table in SQLite Studio or run this command in Linux: sqlite3 "Web Data" ".dump keywords" > keywords.sql SQLite Studio export dialog

  3. Have your colleagues import the keywords, doing the reverse of this process.

Like I said, possible, but painful.

I wrote a Javascript parser to convert the SQL from Web Data into the nearly universal Netscape Bookmark File Format in HTML (ironic that the definitive standard for that format seems to be Microsoft) if you're interested in getting the keywords into other browsers like Firefox or Opera.

If you're interested in an alternative solution, I created Shortmarks to allow you to use the same set of custom search engines in any browser, and I plan to implement the ability to share with others soon. The upcoming release in a few days will have the import code I mentioned above as soon as I'm finished testing the new features.

3
  • 1
    Although I wish Google made it easier, I didn't personally feel "it's enough of a pain that I won't want to try". Patrick's answer was very helpful for me: superuser.com/a/688270/74576 – Ryan May 21 '17 at 16:22
  • William's answer superuser.com/a/1350144/92959 was totally easy. I found Patrick's answer to be very complex compared with William's. – tbc0 Sep 12 '18 at 19:15
  • Would you be open to sharing the JS parser? It sounds like it's exactly what I need! – Marcus Mangelsdorf Nov 25 '20 at 15:32
4

I did following to share my Google Chrome search engine entries and it worked perfectly fine for me:

  1. WINDOWS XP: Go to C:\Documents and Settings\MyUserName\Local Settings\Application Data\Google\Chrome\User Data\Default

    ON WINDOWS 7: Go to C:\Users\MyUserName\AppData\Local\Google\Chrome\User Data\Default

  2. Copy these 3 files: Preferences, Web Data and Web Data-journal

  3. Put those 3 files onto the target machine

3
  • worked for me without "web data-jounal" (just drop both file into the "default" folder, restart chrome) – JinSnow Nov 11 '15 at 5:48
  • So awesome. Worked like charm! Thanks. – digitguy Jun 30 '20 at 0:33
  • This worked. Use "...\User Data\Profie 1" folder if you want to restore the second chrome profile – Faiz Aug 18 '20 at 21:18
3

For me, I'm on Windows 10 and I wanted to copy search engines from my personal chrome profile to my corporate chrome profile. I did the following:

  1. I downloaded SQLite from https://www.sqlite.org/download.html (under "Precompiled Binaries" with the description "A bundle of command-line tools for managing SQLite database files"). I unziped it to c:\utils that's already in my path

  2. I opened up cmd.exe

  3. I changed directory to my default (personal) chrome profile

    cd "%USERPROFILE%\AppData\Local\Google\Chrome\User Data\Default"
    
  4. I exited Chrome entirely (even in the tray). Also, keep a copy of these instructions (or open them in a different browser) because you'll loose them.

  5. I ran the following:

    sqlite3 "Web Data" ".dump keywords" > c:\keywords.sql
    
  6. I changed to the new profile:

    cd "..\Profile 2\"
    
  7. I ran this:

    sqlite3.exe "Web Data" < c:\keywords.sql
    

    I got the following errors, which are okay:

    Error: near line 4: UNIQUE constraint failed: keywords.id
    Error: near line 5: UNIQUE constraint failed: keywords.id
    Error: near line 6: UNIQUE constraint failed: keywords.id
    Error: near line 7: UNIQUE constraint failed: keywords.id
    Error: near line 8: UNIQUE constraint failed: keywords.id
    

    If you get more errors, that means that you added search engines to your new profile. Delete them all, including these new ones just added and re-run this step. Or edit the SQL file by hand.

  8. I fired Chrome back up and now my search keywords work fine.

3

...piggybacking off of https://superuser.com/a/1458616/55621 but trying to update it to work with current versions of Chrome. This worked circa Chrome 88 on a Mac.

To download a JSON file with search engine settings:

(function exportSEs() {
  /* Auxiliary function to download a file with the exported data */
  function downloadData(filename, data) {
    const file = new File([data], { type: 'text/json' });
    const elem = document.createElement('a');
    elem.href = URL.createObjectURL(file);
    elem.download = filename;
    elem.click();
  }

  let searchEngines = [];
  document.querySelector('settings-ui').shadowRoot
    .querySelector('settings-main').shadowRoot
    .querySelector('settings-basic-page').shadowRoot
    .querySelector('settings-search-page').shadowRoot
    .querySelector('settings-search-engines-page').shadowRoot
    .querySelector('settings-search-engines-list#otherEngines').shadowRoot
    .querySelectorAll('settings-search-engine-entry')
    .forEach($el => searchEngines.push(
      {
        name: $el.shadowRoot.querySelector('#name-column').textContent,
        keyword: $el.shadowRoot.querySelector('#keyword-column').textContent,
        url: $el.shadowRoot.querySelector('#url-column').textContent
      })
    )

  downloadData('search_engines.json', JSON.stringify(searchEngines));
}());

To import settings from a JSON file created using the script above:

(async function importSEs() {
  /* Auxiliary function to open a file selection dialog */
  function selectFileToRead() {
    return new Promise((resolve) => {
      const input = document.createElement('input');
      input.setAttribute('type', 'file');
      input.addEventListener('change', (e) => {
        resolve(e.target.files[0]);
      }, false);
      input.click();
    });
  }

  /* Auxiliary function to read data from a file */
  function readFile(file) {
    return new Promise((resolve) => {
      const reader = new FileReader();
      reader.addEventListener('load', (e) => {
        resolve(e.target.result);
      });
      reader.readAsText(file);
    });
  }

  const file = await selectFileToRead();
  const content = await readFile(file);
  const searchEngines = JSON.parse(content);
  searchEngines.forEach(({ name, keyword, url }) => {
    /* Actual search engine import magic */
    chrome.send('searchEngineEditStarted', [-1]);
    chrome.send('searchEngineEditCompleted', [name, keyword, url]);
  });
}());

This is highly likely to break with succeeding versions of Chrome, and there's probably a better way to traverse the dom.

5
  • Poggers. Thank you so much. – Raymo111 Mar 15 at 15:24
  • @Jacob Dalton Trying the import function on Firefox give me the following error: <input> picker was blocked due to lack of user activation.. I am using Firefox 87.0 – Swaranga Sarma Apr 5 at 8:53
  • @SwarangaSarma this an import process for Chrome. Complete the import process in Chrome, the export bookmarks (generates an html file, and then import into Firefox. – Jacob Dalton Apr 5 at 14:10
  • @JacobDalton - I see. Thank you. When I run this on Chrome. I do get the dialog box to select the search_engines.json file but once I complete that what should I expect? It just seems to exit. No errors on the console. – Swaranga Sarma Apr 5 at 17:16
  • This only works if there are very few bookmarks. The Sqlite answers appear to work with more. – Raymo111 Apr 12 at 0:42
0

I wrote a python script which loads definitions from JSON data. Now you can manage your configuration as code:

https://gist.github.com/ninowalker/9952bf435f8acffa3ef59d6c538ca165

This is idempotent (e.g. can be run multiple times; wont add duplicates by keyword).

Works with python2 and OSX. Can be modified to support other platforms.

0

This is how I do it (I don't remember where I found it).

  1. Create a script export_chrome_search_engines.sh:

    #!/bin/sh
    
    DESTINATION=${1:-./keywords.sql}
    TEMP_SQL_SCRIPT=/tmp/sync_chrome_sql_script
    echo "Exporting Chrome keywords to $DESTINATION..."
    cd ~/.config/google-chrome/Default
    echo .output $DESTINATION > $TEMP_SQL_SCRIPT
    echo .dump keywords >> $TEMP_SQL_SCRIPT
    sqlite3 -init $TEMP_SQL_SCRIPT Web\ Data .exit
    rm $TEMP_SQL_SCRIPT
    
  2. Create a script import_chrome_search_engines.sh:

    #!/bin/sh
    if ps -x | grep -v grep | grep Google\ Chrome > /dev/null; then
        echo "Close Chrome and try again..."
        exit 1
    fi
    
    SOURCE=${1:-./keywords.sql}
    #SOURCE=$1
    TEMP_SQL_SCRIPT=/tmp/sync_chrome_sql_script
    echo
    echo "Importing Chrome keywords from $SOURCE..."
    cd ~/.config/google-chrome/Default
    echo DROP TABLE IF EXISTS keywords\; > $TEMP_SQL_SCRIPT
    echo .read $SOURCE >> $TEMP_SQL_SCRIPT
    sqlite3 -init $TEMP_SQL_SCRIPT Web\ Data .exit
    rm $TEMP_SQL_SCRIPT
    
  3. Make them executable:

    chmod +x export_chrome_search_engines.sh import_chrome_search_engines.sh 
    
  4. To export, shut down Chrome and run:

    ./export_chrome_search_engines.sh
    cp ~/.config/google-chrome/Default/keywords.sql /tmp/
    
  5. To import, shut down Chrome and run:

    cp /tmp/keywords.sql  ~/.config/google-chrome/Default
    ./import_chrome_search_engines.sh
    
0

Use Google Takeout https://takeout.google.com to export your Chrome Search Engines to a json file.

Select Chrome, and either select All Chrome data included, or SearchEngines.

The export will contain a SearchEngines.json file.

enter image description here enter image description here enter image description here

-2

As of now, no you cannot. However, you can share bookmarks with your colleagues.

Link to Google Bookmark sharing as of now, Google App users are not able to share bookmarks, or lists of bookmarks.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.