Open SQLite on Mac thumbnail

How to Open a SQLite File on Mac (Terminal + No-Install Way)

Macs have a hidden advantage when it comes to SQLite. The sqlite3 command-line tool is already installed. You don’t need to download anything to open a database. You just need to know where to type.

If you’d rather not use Terminal, that’s fine too. You can open a SQLite file in Safari or Chrome with a free online viewer, or install a desktop app. This guide walks through all three, step by step, and shows where Mac apps keep their SQLite files.

Method 1: Open it in your browser (easiest)

This method needs no Terminal and no install. It’s the best choice if you want to click around and look at data.

  1. Open Safari, Chrome or Firefox.
  2. Go to our free online SQLite viewer.
  3. Drag your .db, .sqlite or .sqlite3 file from Finder onto the drop zone. Or click Choose file and pick it.
  4. Click any table in the sidebar to see its rows.

From there you can sort columns, search across every column, check the table structure, run SQL, and export to CSV or JSON.

Your file is read inside the browser. It isn’t uploaded to any server. You can confirm this by turning off Wi-Fi after the page loads. The viewer keeps working.

Method 2: Use Terminal and sqlite3 (built in)

Every Mac includes sqlite3. Here’s how to use it.

Step 1: Open Terminal

Press Cmd and Space to open Spotlight, type Terminal, and press Return.

Step 2: Open your database

Type sqlite3 followed by a space, then drag the file from Finder into the Terminal window. macOS fills in the full path for you. Press Return.

sqlite3 /Users/yourname/Desktop/mydata.db

You’ll see a prompt that looks like sqlite>.

Step 3: Explore

Try these commands one at a time:

.tables
.schema customers
.headers on
.mode column
SELECT * FROM customers LIMIT 10;

What they do:

  • .tables lists every table.
  • .schema customers shows how the customers table is built.
  • .headers on and .mode column make output easier to read.
  • The SELECT line shows the first ten rows.

For wide tables, .mode box or .mode table draws neat borders in recent versions. If your version doesn’t support them, stick with column mode.

Step 4: Quit

Type .quit and press Return, or press Ctrl and D.

Export to CSV from Terminal

sqlite3 can write query results straight to a CSV file:

.headers on
.mode csv
.output ~/Desktop/customers.csv
SELECT * FROM customers;
.output stdout

The file appears on your Desktop, ready for Numbers or Excel. Our SQLite to CSV guide covers more options.

A warning about typos

If you mistype a file name, sqlite3 creates a brand new empty database with that name. If .tables shows nothing, check the path. Dragging the file into Terminal avoids this problem.

Method 3: Install a desktop app

If you’ll use SQLite regularly, a Mac app can be more comfortable than Terminal.

  • DB Browser for SQLite: free and open source. Download it from sqlitebrowser.org, drag it to Applications, and open your file with Open Database.
  • SQLiteStudio: free, open source, feature rich.
  • TablePlus: polished and fast, with a limited free tier.

The first time you open a downloaded app, macOS may warn that it’s from the internet. Click Open if you trust the source. Our best SQLite viewers guide compares these apps in detail.

Quick Look and double-clicking on Mac

Pressing the space bar on a file in Finder opens Quick Look. For SQLite files, Quick Look shows a generic icon, not your data. Double-clicking usually opens nothing useful either, because macOS has no default app for .db files.

If you install DB Browser for SQLite and want double-clicking to work, right-click a .db file, choose Get Info, pick DB Browser under Open with, and click Change All. Do the same for .sqlite and .sqlite3 if you use them.

Which method should you choose?

Your goalBest method
Quick look without TerminalOnline viewer
Fast answers, comfortable typing commandsTerminal and sqlite3
Regular editing with a visual interfaceDB Browser for SQLite
Large files over 1 GBTerminal or a desktop app
Share results with a colleagueOnline viewer, then Export CSV

Where Mac apps keep SQLite files

Many Mac apps store data as SQLite. Most of it lives in your Library folder, which is hidden by default.

To open it, click Finder, hold the Option key, and choose Go, then Library. Or press Cmd, Shift and G, and type ~/Library.

Common places to look:

  • ~/Library/Application Support/ for most app data
  • ~/Library/Containers/ for sandboxed apps
  • ~/Library/Group Containers/ for data shared between an app and its extensions
  • ~/Library/Safari/History.db for Safari history
  • ~/Library/Messages/chat.db for iMessage history

Some of these folders are protected. Terminal and other apps may need Full Disk Access to read them. You can grant it in System Settings under Privacy and Security, then Full Disk Access. Only grant access to apps you trust, and consider removing it when you’re done.

Copy before you open

Always copy a database before opening it, especially if the app is still running. Copy any matching -wal and -shm files too. Recent changes can live in the -wal file until the app saves them into the main database.

Reading Apple app databases

Databases from Apple’s own apps and many third-party Mac apps often use Core Data. You’ll recognize it by table names that start with Z, like ZNOTE or ZITEM.

Dates in these files often count seconds from January 1, 2001, not 1970. To read them, add 978307200 before converting:

SELECT datetime(ZCREATIONDATE + 978307200, 'unixepoch') FROM ZNOTE LIMIT 10;

Our guide to .sqlitedb files explains Core Data layouts in more detail.

Opening SQLite files from an iPhone backup on Mac

When you back up an iPhone to your Mac with Finder, the backup is stored in:

~/Library/Application Support/MobileSync/Backup/

Files inside are stored under long hashed names without extensions. Many are SQLite databases. If the backup is encrypted, you’ll need the backup password and a dedicated tool to decrypt it first. A normal SQLite viewer can’t read encrypted backups.

Handy sqlite3 tricks for Mac users

Once you’re comfortable in Terminal, a few extra commands make sqlite3 much nicer to use.

Open a database read only

If you want to be sure you can’t change anything by accident, open the file in read-only mode:

sqlite3 -readonly ~/Desktop/mydata.db

Any attempt to insert, update or delete will fail with an error. This is a good habit when poking around app databases.

Run one query without entering the shell

You can pass a query straight on the command line:

sqlite3 ~/Desktop/mydata.db "SELECT COUNT(*) FROM customers;"

This prints the answer and exits. It’s handy in scripts and shortcuts.

Save your favourite settings

Create a file called .sqliterc in your home folder with these lines:

.headers on
.mode column

sqlite3 reads this file every time it starts, so you never have to type those commands again.

Check your SQLite version

sqlite3 --version

Some newer features, like .mode box and PRAGMA table_list, need a recent version. If yours is older and you want the latest, you can install a newer build with Homebrew by running brew install sqlite. The browser viewer always runs a modern SQLite build, so it’s a simple fallback.

Troubleshooting on Mac

“Operation not permitted”

Terminal doesn’t have permission to read that folder. Grant Full Disk Access to Terminal, or copy the file somewhere else first.

“Error: file is not a database”

The file is encrypted, compressed or not SQLite. See our file is not a database guide.

“Database is locked”

The app that owns the file is still running. Quit it fully, or copy the file first. More in our guide to the database is locked error.

Output is messy in Terminal

Run .headers on and .mode column. For very wide tables, the browser viewer is easier to read.

Want the technical detail? See the official SQLite command-line shell documentation.

Frequently asked questions

Does macOS come with SQLite?

Yes. The sqlite3 command-line tool is included with macOS. Open Terminal and type sqlite3 to check.

Can I open SQLite files in Numbers?

Not directly. Export the table to CSV first, then open the CSV in Numbers.

Is it safe to open SQLite files from the Library folder?

Viewing is safe if you work on a copy. Don’t edit the live database an app is using.

Can I use the online viewer on an older Mac?

Yes, as long as your browser supports WebAssembly. Any recent version of Safari, Chrome or Firefox does.

Summary

On a Mac, you can open a SQLite file three ways. Drop it into our free online SQLite viewer for a quick, private look. Use the built-in sqlite3 command in Terminal for fast answers and CSV exports. Or install DB Browser for SQLite for regular visual work. Whichever you choose, copy the file first. For a wider overview, see our main guide on how to open a SQLite file.

Similar Posts