Skip to main content

Send us a Topic or Tip

Have a suggestion for the blog? Perhaps a topic you'd like us to write about? If so, we'd love to hear from you! Fancy yourself a writer and have a tech tip, handy computer trick, or "how to" to share? Let us know what you'd like to contribute!

Thanks for reaching out!

Recovering Deleted Safari Browsing History on a Mac

Transparent Safari Icon

Over the years, we’ve provided a lot of tips on how to recover space on your Mac, one of which is to delete your browsing history in Safari. That’s all fine and good, and it will definitely open up megabytes of space, but what if that browsing history was your only link to an important website or page? Today we’re going to look at how to recover a deleted Safari browsing history.

Restore From Time Machine

To restore your deleted Safari history, you’re going to need a Time Machine backup or another backup file from before the date that you deleted your browsing history. (note that this isn’t always the case on public machines like those at a library or school). If the Mac is only used by you or a small group of users, and you have Time Machine backups running constantly, then this is the method to use.

  1. If Safari is currently open, quit out of it. Next, click and hold on the Finder icon (the smiling face at the far left side of the Dock) until the pop-up menu appears, then select “New Finder Window”.
  2. A Finder window appears on the screen. Go to the menu bar, select Go > Go to Folder, type in ~/Library/Safari (see screenshot below), and then click the Go button.
Enter this path in the Go to Folder dialog, then click the Go button
Enter this path in the Go to Folder dialog, then click the Go button
  1. This opens the Finder window to the ~/Library/Safari directory.
  2. Make sure that the Time Machine icon appears on the right side of your Mac menu bar. If it doesn’t, launch System Preferences, then Time Machine, and then check the box next to “Show Time Machine in menu bar”
  3. In the open Finder window, find the file named “History.db”. Click it once to select it, then select “Enter Time Machine” from the Time Machine menu (see screenshot below).
Select History.db, then choose Enter Time Machine from the Time Machine menu
Select History.db, then choose Enter Time Machine from the Time Machine menu
  1. Once Time Machine is open, a list of all backups of the History.db file appears (see screenshot below). You’ll want to use the up arrow to go “back in time” to an earlier date before you deleted your Safari browsing history, and then click the Restore button. Note that if you’re looking from a Safari browsing history from a long time ago, it’s possible to use the slider on the far right of the Time Machine screen to go back months or years.
Time Machine displays a history of the files in the Safari folder.
Time Machine displays a history of the files in the Safari folder.
  1. Once Time Machine has restored the “History.db” file, launch Safari.
  2. From the menubar for Safari, select History > Show All History. A grid-like list of your browsing history appears in a browser window, showing all of the visits you’ve made on your journey around the web (see image below).
The Safari browsing history
The Safari browsing history

One comment about that History.db file. It’s actually an SQLite database file and can be queried or searched with almost any SQL database tool, including this free app – DB Browser for SQLite. However, it’s much easier for most users to simply use the search bar in the upper right corner of the History window to search for a particular item.

If you don’t have a Time Machine backup or another backup from an earlier time, there’s really no way to recover your browsing history. This is yet another reason why we constantly recommend getting an inexpensive external drive, hooking it to your Mac, and then setting up Time Machine to back up the device continuously.

A Note About DB Browser for SQLite

Curious about your browsing history? For example, perhaps you’d like to know how many times you’ve visited a specific web page. The app discussed in the previous section—DB Browser for SQLite—is a handy tool for getting some information from the History.db file that might be useful.

After downloading and installing DB Browser for SQLite, launch the app, find the History.db file (the first part of this article shows you how to do this), then drag it to the DB Browser window. The file opens in the Database Structure view; what most users want to do is browser the data stored in one of the SQLite tables.

As an example, I’ve opened the History.db file in DB Browser, then selected the history_items table from the Table pop-up list. The screenshot below shows the contents of that table, which include an ID number, the URL of a visited site, a “domain_expansion” for each site, and various other columns in this table.

I don’t recommend using DB Browser for SQLite for anything other than just browsing the History.db file unless you really know what you’re doing! If you decide to play with deleting records, be sure to have a backup of History.db in case you corrupt it.

  • Originally posted July 13, 2018

Steve Sande
the authorSteve Sande
Contributing Author
Steve has been writing about Apple products since 1986, starting on a bulletin board system, creating the first of his many Apple-related websites in 1994, joining the staff of The Unofficial Apple Weblog in 2008, and founding Apple World Today in 2015. He’s semi-retired, loves to camp and take photos, and is an FAA-licensed drone pilot.
Be Sociable, Share This Post!

Leave a Reply


  • Sadly, Apple keeps changing the way MacOS Safari stores its history. For me, Safari 12.1.2 doesn’t use ~/Library/Safari/History.db:
    % ls -lart ~/Library/Safari | grep History
    -rw-r–r–@ 1 nigel staff 0 17 Feb 2017 History.db-lock
    -rw-r–r–@ 1 nigel staff 0 15 Jun 11:47 History.db-wal
    -rw-r–r–@ 1 nigel staff 7446528 15 Jun 11:47 History.db
    -rw-r–r–@ 1 nigel staff 32768 15 Jun 11:48 History.db-shm
    -rw-r–r–@ 1 nigel staff 1012 2 Oct 18:18 CloudHistoryRemoteConfiguration.plist
    -rw——-@ 1 nigel staff 1314816 3 Oct 11:34

    but I did find recent history links in ~/Library/Caches/Metadata/Safari/History

  • Thanks. It would be convenient if the “Originally posted July 13, 2018” was shown on the top of the article, indicating if it is identical or has been updated. Otherwise, you may read or save it for future offline reference, just to find that you already have it.

  • Very valuable tip that just saved my bacon today.

    One addition: make sure you set the Safari preference General / Remove history items to “Manual” before you do this… otherwise, as you are perusing the old history you just retrieved, it will magically disappear right before your eyes!

  • Thanks for sharing this information. Because of this I was able to locate the History.db file. I’m unable to open the file in DB Browser, however – whether I drag it into the window or use the “Open Database …” tool. Either way I receive the rather circular error

    Could not open database file.
    Reason: unable to open database file

    Any idea what could be causing this or how to work around it?

    My goal is not to restore deleted history, but simply to access my history for another project.

    Thanks again!

  • Thanks, but it does not work with Safari 12.1.2 (12607.3.10) on macOS 10.12.6 (16G2136) Sierra.

    After restoring
    with Safari closed (otherwise it does not stick), I cannot show the desired web page contents if not connected to Internet.

    When connected to Internet, Safari does not show the older contents of such web page, that are the ones that I want, but the new updated web page which shows no contents at all. This is a web page showing the tracking of a parcel. That is why I wanted to show the older content.

    Is there any way to recover such older web page contents from any backup? I have backups made with Time Machine, SuperDuper and Carbon Copy Cloner.


  • So how do you do a secure delete of the shitory file, including all time machine copies?

    Or a secure delete of anything?