Practical coding
Published in

Practical coding

Export Safari reading list using Python

Clean up your teeming reading list.

Image credit: author (Oliver K. Ernst)

Here is the GitHub repo. with the script.

If you are like me, your reading list is overflowing. Mine is over 1000+ entries. I use it daily to quickly remind myself of useful websites I’ve found, but I never bother to clean it up after those sites have used their purpose.

I didn’t want to clean it up manually by clicking through 1000+ items with a mouse is tedious. There is a shortcut to remove all items, but before doing that I wanted to export the data.

JSON exported reading list.
CSV exported reading list.

Here’s how it’s done.

Your reading list is stored in ~/Library/Safari/Bookmarks.plist (at least, in Mac 11.4 Big Sur it is). Additionally, icons for the reading list are stored in ~/Library/Safari/ReadingListArchives .

To read the .plist file format in Python, it is easiest to use the plistlib library:

pip install plistlib

The complete script

Here is the complete script — the explanation is below:


Basic usage:

  • Export to CSV:
python csv reading_list.csv

will write the reading list to reading_list.csv.

  • Export to JSON:
python json reading_list.json

will write the reading list to reading_list.json.


  • Also copy the reading list icons:
python csv reading_list.csv — dir-icons-out reading_list_icons

copies the icons to the folder reading_list_icons. They match up to the entries through the WebBookmarkUUID key.

  • Specify the source directory for the icons:
python csv reading_list.csv — dir-icons ~/Library/Safari/ReadingListArchives

The default is ~/Library/Safari/ReadingListArchives.

  • Specify the source directory for the reading list .plist file:
python csv reading_list.csv — fname-bookmarks ~/Library/Safari/Bookmarks.plist

The default is ~/Library/Safari/Bookmarks.plist.

  • Include cached data for the websites:
python csv reading_list.csv — include-data

The data is written to the Data field. The default is the--exclude-data option, which excludes the data.

Explanation of the script

First, copy the plist file for safety:

Next, find reading list elements in this terribly formatted dictionary:

Convert the reading list dictionaries to custom objects:

Finally, dump the entries to JSON or CSV:

Final thoughts

Now we have a backup of the reading list. A future project may write an edited CSV or JSON file back to the reading list plist format recognized by Safari.




Practical coding and machine learning publications that fill in the gaps

Recommended from Medium

READ/DOWNLOAD$] Adaptive Code: Agile coding with design patterns and SOLID principles (Developer…

Operate And Manage A Relational Database On The Cloud

CVE-2020–3119 Cisco CDP Stack Overflow Analysis

5 principles of cloud native apps

Towards Tendermint Core 1.0

New Jina primitive data types!

How to join Sub-only Discord

How to build your own PoC framework — part 2

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Oliver K. Ernst, Ph.D.

Oliver K. Ernst, Ph.D.

Coding, ML, AI —

More from Medium

5 Python Libraries to Build Command Line Tools

TIL: Debugging Google Cloud Functions, written in Python, in Visual Studio Code, using functions…

Fix “Failed To Create JVM ” error while installing TeradataStudio on MacOS Spur.

DIY Stream Deck with Raspberry Pi and 5'’ Touch Screen