I'm trying to figure out how to determine the time websites were visited in the Safari history. (I can't imagine why this isn't easy to do like in every other browser I've ever used).

NOTE: I'm running Safari 9.0.3 and El Capitan 10.11.3.

I've done some research and found some files in ~/Library/Safari. The file History.db file looks possibly promising but I haven't been able to figure out how to find the timestamp from this yet.


I just tried this in 10.11.4 and it works; you can see the history. If someone clears the cache, this goes away.

Go to the following location:


From here you can change the view to List View and sort by Date Modified.


So I woke up today to my sleep-tracker app telling me I went to bed an hour earlier than I thought I did, so naturally I assumed the app was the one who made the stupid mistake. Luckily I'd surfed the web before going to bed, but apparently Apple changed things up again as of High Sierra or Safari 11 so the other answers didn't work for me.

I found out how to get the visit times, and since I went way to far to get to the bottom of this highly unimportant issue already, I thought I'd share my findings here:


Okay so I got carried away a little more and wrote a bash one-liner to do all the hard work for you. Just open the terminal and copy-past it in. It should work without having to install anything, unless apple has changed something again in the mean time.

You can ignore the empty lines in the output (they are http-redirects) and you can change the last number 30 in the command to filter the number of lines you want to see.

sqlite3 ~/Library/Safari/History.db 'select visit_time,title from history_visits order by visit_time desc;' \
 | while read i; do d="${i%%.*}"; echo "$(date -r $((d+978307200))) | ${i#*|}"; done \
 | head -n 30

Original answer

So instead of having a simple folder with all the history like before, they now write the history into a database. Here's how you get the info if you really want to:

  1. The data is now stored in an SQLite Database, so you're gonna need some tool to read that. I suggest the DB Browser for SQLite. Just install it the usual way.
  2. Now open the database file. It is located here: /Users/[yourname]/Library/Safari/History.db.
  3. In the Browse Data Tab click the Table: dropdown and select history_visits. History_visits screenshot
  4. Now, sort by visit_time and find the thing you are interested in.
  5. Those numbers under the visit_time column are a Core Data Timestamp, so to get something human-readable you need a converter. Simply use this one: https://www.epochconverter.com/coredata

Hope this solves your history-related conundrum.

  • 1
    You are awesome mate!! Works like a charm in Mojave too!! – Jeeva Dec 20 '18 at 6:02
  • 2
    The other solutions werent working on mojave but this works great!! Thank you so much mate :) – Flaming_Dorito Feb 24 at 23:12
  • If it fails just copy the database file to another place, or maybe closing safari is sufficient – Simon Mar 27 at 22:54

I modified the oneliner that meonlol gave above. This way it is just pure SQL query.

sqlite3 ~/Library/Safari/History.db \
    'SELECT datetime(visit_time+978307200, "unixepoch", "localtime"), title
     FROM history_visits
     ORDER BY visit_time DESC
     LIMIT 30;'

In Mojave, and possibly later, accessing the file in terminal seems limited. Either grant full access to Terminal in System Preferences or use Finder to open ~/Library/Safari and then copy History.db to somewhere else.

  • 1
    +1 on copying the database to a location outside of the Library tree (at least in Mojave). Seems a required step to access the database. – DaveL17 May 20 at 11:53
  • 1
    You still can access the file on Mojave if you grant Terminal full access in System Preferences. – nohillside May 26 at 12:23

This path has changed in Sierra

In 10.12.6 go to



In Sierra now just use Finder to search for a folder called Safari, then go into the History folder, and you can change the view as mentioned before.

You must log in to answer this question.

protected by bmike May 25 at 22:31

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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