Mac OS X – Export Google Chrome Browsing History to CSV File from the Terminal

This post is just for my own personal reference, but you can use it too if you like. Just make sure to change the “UserName” below to whatever that user’s home directory is. I’ve mashed the code together from the following sources, changed it to export in csv format (making it easier to import into Excel or Open Office for further manipulation), made it into a one-liner for sake of ease, put the data in ascending order based on last URL visit date, and converted the dates into human readable format.

/usr/bin/sqlite3 -csv -header /Users/UserName/Library/Application\ Support/Google/Chrome/Default/History "SELECT, urls.url, urls.title, urls.visit_count, urls.typed_count, datetime((urls.last_visit_time/1000000)-11644473600, 'unixepoch', 'localtime') AS last_visit_time, urls.hidden, urls.favicon_id, datetime((visits.visit_time/1000000)-11644473600, 'unixepoch', 'localtime') AS visit_time, visits.from_visit, visits.visit_duration, visits.transition, visit_source.source FROM urls JOIN visits ON = visits.url LEFT JOIN visit_source ON = order by last_visit_time asc;" > history.csv

Leave a Reply