Firefox/Browsing history database

This guide shows how to read the browsing history database created by the Mozilla Firefox web browser. The title of this page can be understood as both "browsing through the database" and "the database that contains the browsing history".

The database is named  and located in the profile folder and is in the SQL (Structured Query Language) 3 format. To facilitate using the commands, you may navigate to the profile folder directory, copy the database file into your working directory, or put the path to the database file in a variable.

Simple searching
Some data can be viewed directly through text editors and command line tools, but they are inconveniently wrapped in a mess of non-human-readable binary data.

When viewed through the command line simple checks for the existence of a title or URL can be performed using  (parameters: search binary file, case insensitivity, list files only). Title searches can be performed using, where thirty characters around the string are also shown for context.

can partially filter out junk characters for a  pipe. Additionally,  creates a line break before each URL.

Listing the "tables"
First, we have to find the names of the "tables" that the database contains. These are the various areas within the database file that store parameters including the main history, bookmarks , favicons , and user-specified keywords.

This can be done either directly,

sqlite3 places.sqlite .tables

…or within an sqlite3 session.

The tables may vary depending on the browser's version.

A list of columns within a table can be obtained through, as shown here in this example:

Since the default pipe character in the output could interfere with a command line interpreter's URL highlighting, which makes the selection of URLs less convenient, a custom separator character can be specified using  in the   file to prevent this. For example, a space character is specified using. Create that file if it does not exist.

Reading the data
Tables from the database can be read through the  operation, with table columns as a dot notation after table names. For example, the following command obtains time stamps and URLs.

An example output line is: 2012-04-15 15:56:56|http://www.youtube.com/watch?v=CiuK01bf9X8|Die Pinguine aus Madagascar - Rico Intel Werbung (Operation Super Rico) - YouTube

With custom space separators: 2012-04-15 15:56:56 http://www.youtube.com/watch?v=CiuK01bf9X8 Die Pinguine aus Madagascar - Rico Intel Werbung (Operation Super Rico) - YouTube

The  part is responsible for converting the Unix epoch time written in the database into a human-readable date and time stamp such as.

The  pipe makes the entries appear chronologically. This can be desirable for exporting since the order the entries are written in the database is not exactly chronological. Alternatively,  can be used if natively supported by your sqlite instance:

After, sorting order can be specified using   (ascending) or   (descending).

Finally, the  pipe allows directly scrolling through the entries in the terminal software through the "less" utility which enables interactive bi-directional scrolling using the arrow keys and pgUp and pgDn and string searching using " / " (slash). The  parameter makes string searching case-insensitive. Case-sensitivity can also be toggled within the utility by typing.

Optionally, the history can be exported by redirecting the output into a text file by using  instead of.

This also allows viewing individual time stamps for repeated visits of the same page, since Firefox records a time stamp for each visit, whereas Google Chrome, while recording visit count, overwrites the previous timestamp, meaning only the most recent visit date/time is recorded by Chrome. On Firefox, the former XUL-based extension "Norwell history tools" enabled viewing individual visit times too, but XUL extensions are unsupported on Firefox versions 57 "Quantum" (November 2017) onward, and no known successor to the extension has been released since as of 2022.

Shortcut function
Opening the database file can be facilitated through a shortcut function:

To load this function automatically, add it to the  file.

Raw data
To extract the raw data from the database in human-readable form, run. This can be helpful for performing simple title or URL searches, but not for dates, since they are not stored in a human-readable format in the database.

Repairing a corrupted database
If Firefox happens to rename the  file to , it means it has detected an error whlist reading the database. To fix it, do the following after choosing the browser's profile folder as working directory:

This is not guaranteed to fix the problem, but it is worth a try.