When most Mac users delete their Safari browser history, the last thing they want is for it to ever come back. But from time to time, users clear their browsing history on accident or realize that it contained an important website whose address they don’t remember anymore.  

If you’re currently in the same situation, then this article will help you solve it because it describes the top 3 ways to recover deleted Safari history on Mac. But before we get to them, we need to briefly explain what Safari browser history actually is and where you can find it. 

What Is Safari History and How to Find It?

Safari history is a database containing previously visited websites. Just like most other web browsers, Safari keeps it automatically to make it easier for users to revisit familiar websites without having to enter their addresses over and over again. 

To view Safari history

  1. Open Safari on your Mac. 
  2. Choose the History option.
  3. Click Show All History 

Safari history

You should see a table with two columns and multiple rows. The first column from the left shows the names of previously visited websites, while the second column shows their addresses. Individual entries are grouped by date, so you can easily go back in time and view history on Safari Mac from a specific date. Alternatively, you can use the search bar in the top-right corner to find all history entries that contain specified keywords. 

All the information that you can see when you click the Show All History button is stored on your hard drive, inside a file called History.db. This file is located in the ~/Library/Safari/ folder.

To find and open the History.db file

  1. Open Finder.
  2. Choose the Go option.
  3. Click Go to Folder. 
  4. Enter the path to the Safari history file location in the textbox and click OK.
  5. Open History.db with TextEdit. 

History.db inTextEdit

You will see a long text file that’s anything but easy to decipher. That’s because History.db is actually an SQLite database file, and it’s not intended to be viewed in a regular text editor. Instead, you should open it using a database browser like DB Browser for SQLite, which you can download for free right from its official website. 

After installing DB Browser for SQLite, launch the app and click Open Database. Select the History.db file and switch to the Browse Data tab. Finally, select the history_items table.

View History.db in DB BrowserYou should see a rather nicely formatted list of URLs and corresponding domain names, and you can sort it alphabetically. 

How Can Safari History Be Deleted and When It Can Be Recovered?

Let’s take a look at some common reasons for deleting Safari history and whether it can be recovered:

  • Intentional deletion: Many Safari users like to keep their browsing history squeaky clean to prevent others from examining their online activity. That’s all fine and good until you need the address of a website you’ve visited a long time ago and can’t remember it.  
  • Accidental deletion: All you need to do to delete your Safari history is click the Clear History button and confirm your decision. By default, Safari deletes only the last hour of browsing history, but you can also tell it delete all history in one go. What often happens is that users want to delete only the last hour but don’t notice that the option to delete all history is selected, causing their entire browsing history to disappear immediately. 
  • Private Browsing: Safari allows you to open a Private Window (Command+Shift+N) that prevents your browsing history from being recorded. Safari users sometimes don’t realize that they’re browsing the web in the Private Window and wonder why their browsing history hasn’t been recorded. 
  • Formatting: When reinstalling macOS, it’s sometimes a good idea to first format the system drive to start with a clean slate. It goes without saying that formatting doesn’t erase just Safari history but also all other files stored on the hard drive. 
  • Hackers: Mac users are relatively safe from malware since most cybercriminals target Windows computers, but that doesn’t mean they are completely immune. From ransomware to remote desktop hacks, there are multiple cyber-threats that can cause Mac users to lose their entire Safari browsing history in the blink of an eye. 

Fortunately, in all the above-described situations—with the exception of Private Browsing (which prevents browsing history from being recorded)—it’s possible to restore Safari history using native tools and third-party software.

How to Perform Safari History Recovery?

There are three main methods for recovering Safari history on Mac, and we describe all of them in the same order we recommend you try them. 

Method 1: iCloud

If you’re using iCloud to back up your Safari data and keep it synchronized across devices, then you can recover deleted Safari history using your iPhone or any other iOS and iPadOS device that still contains the original browsing history data. 

Here’s what you need to do: 

  1. Open the Settings app on your iPhone or iPad.iPhone settings
  2. Tap on your name.
  3. Select iCloud.
  4. Locate Safari and toggle the switch next to it until you’re prompted to merge your data. 
  5. Click Merge. Merge safari data with iCloud

This way, you force your iPhone to overwrite Safari browsing history in iCloud, which, in turn, allows you to recover deleted Safari history on Mac just by turning on the Safari option in iCloud settings (see the last section of this article for a step-by-step guide). 

Method 2: Time Machine

Safari history recovery can also be performed using Time Machine. While you could choose the nuclear option and restore your entire Mac to an earlier state from Recovery, it’s much less time consuming to only recover the History.db file, which, as we’ve explained earlier in this article, contains all previously visited websites and is stored in the ~/Library/Safari directory. 

To restore deleted history of Safari browsing using Time Machine

  1. Close Safari 
  2. Open Finder and select Go -> Go to Folder.
  3. Enter ~/Library/Safari and click the Go button.Open safari folder
  4. Scroll down until you find the History.db file and select it. 
  5. Click the Time Machine icon located in the Menu Bar and choose Enter Time Machine.Enter time machine
  6. Go back in time until you see a version of the History.db file that contains your lost Safari browsing history.
  7. Click Restore to restore the selected file.Restore History.db file

The next time you open Safari, your browsing history should be back. That’s how easy it is to retrieve deleted history of Safari browsing using Time Machine. 

The only problem with this method is that it will work only if Time Machine was enabled prior to the data loss incident. If it wasn’t, then you won’t have any backup of the History.db file to recover. In that case, you can still attempt to recover deleted Safari history using data recovery software. 

Method 3: Disk Drill

Disk Drill is a popular data recovery software app for Mac and Windows that can quickly and reliably recover several hundred file formats from Mac’s internal hard drive as well as external hard drives, USB flash drives, memory cards, and other commonly used storage devices with NTFS, FAT, FAT32, exFAT, EXT3/EXT4, HFS, and APFS file systems. 

Disk Drill is perfect for recovering a History.db that has been accidentally deleted or lost during formatting. As long as the file hasn’t been overwritten, you should be able to completely recover it. Even if the file ends up being partially corrupted, you can still open it using a database browser like DB Browser for SQLite or any text editor, such as Apple’s TextEdit. 

To restore deleted history of Safari browsing with Disk Drill

  1. Download and install Disk Drill. Install Disk Drill
  2. Launch Disk Drill and select your main hard drive. 
  3. Click Search for lost data. Scan the disk
  4. Type “history.db” into the search field in the top-right corner and hit Return. 
  5. Select the deleted History.db file and click the Recover button. Find History.db file and recover
  6. Choose a safe recovery destination and click OK. 

You can then view deleted Safari history in your favorite text editor or database browser. To view it in Safari, you need to copy the recovered History.db file to ~/Library/Safari and overwrite the file that’s currently in the location. 

How to Prevent Safari History Loss?

The best way to prevent Safari history loss is to turn on Safari in iCloud preferences. That way, iCloud will automatically back up your Safari data to the cloud, allowing you to keep it synchronized across your devices and easily retrieve it should anything happen to your Mac. 

To back up your Safari browsing history with iCloud

  1. Open the System Preferences app on your Mac.
  2. Select iCloud.
  3. Check Safari. Back up Safari history in iCloud

Your Safari browsing history will be automatically synchronized across all Apple devices that use the same Apple ID.