How to open a .db file on Mac

A .db extension means “database” by convention, not a particular file format. Identify the file before choosing an app to open it.

1. Check the file type

In Terminal, replace this path with your file’s actual location. Keep the quotes if its name contains spaces.

file "/path/to/database.db"

For an ordinary SQLite database, the result usually identifies SQLite 3. You can also examine the first 16 bytes:

hexdump -C -n 16 "/path/to/database.db"

A normal SQLite 3 header contains SQLite format 3 followed by a zero byte. This identifies the format, not the integrity of the rest of the file. An empty SQLite database can be zero bytes, and an encrypted database will not necessarily expose this header. See the SQLite file format.

2. Try a read-only command-line connection

sqlite3 -readonly "/path/to/database.db"
.tables
.schema
.quit

-readonly prevents writes through this connection and avoids creating a new database if you mistype the filename. .tables lists tables; .schema prints their definitions. These dot commands belong to the sqlite3 shell, not SQL query editors.

3. Browse it graphically with Petti

In Petti, choose Open Database, select the file, then select a table. You can browse, search and filter without unlocking or purchasing a license. Petti’s SQLite viewer is for SQLite files; changing another format’s extension does not convert it.

If the file will not open

If the database belongs to a running app, do not copy just the main file and assume it contains all recent changes. WAL sidecar files can contain committed data.