Exporting and synchronising Chrome bookmarks

Google Chrome is my primary browser and I use bookmarks extensively for saving links. My bookmarks are organised by topic into different folders and sub-folders.

With certain topics, I wanted to have access to bookmarks on my smartphone, however I did not want to sign in to Chrome in order to synchronise all the data across my different devices. So instead I decided to build a simple web page which displays bookmarks from a certain folder (if you’re interested: it’s a folder where I save all the good recipes that I discover online). In order to populate the page, I needed to retrieve the bookmarks.

It’s possible to export bookmarks from Chrome as an HTML file, however I wanted to do it programmatically and wrote a script that can be run from the terminal.

Export and sync script

It turns out that Chrome bookmarks can be accessed directly from a JSON file which is a bit hidden. On my Mac OS system it’s stored in a file without an extension found here: /Library/Application Support/Google/Chrome/Default/Bookmarks. To export the bookmarks I wrote a Node.js script that goes through this file, extracts links from a specified bookmark folder and saves them in a JSON file. If the output file already exists, the script checks for already exported bookmarks and those that have been deleted and updates the output file accordingly.

The script uses only built-in Node.js modules and can be executed by running node export-sync-bookmarks.js in the terminal, provided that Node.js is installed. Only two things need to be defined:

  • bookmark folder name
  • output filename

The full script can be found here.

Using the output JSON file I was able to populate the web page (I also included some additional useful notes for each bookmark) and can now access all my saved recipes from any device!

So if you’re looking for a way to export and synchronise your bookmarks programmatically, you may find this script useful. To go a step further, it could be set to get executed automatically, for example once a day. This way the bookmarks would always stay up-to-date.

Let me know on Twitter if you find it useful!