DigiVibeTech

How to open a SQLite database file without changing it

You've got a file called app.db, data.sqlite or history.sqlite3, maybe from a phone backup, a browser profile, a mobile app you're building or a colleague's project. You want to see what's in it. You don't want to break it.

SQLite files are just single files on disk, so any tool that opens them can also write to them. Most of the time that's fine. But if the file belongs to a running app, or it's the only copy, a stray click or an app that "upgrades" the file on open is enough to cause trouble. Here are four ways to look inside, and how each one keeps the file safe.

First: make a copy, and copy the -wal file too

If there's a file next to your database with the same name plus -wal (for example app.db-wal), copy both. SQLite in WAL mode keeps recent changes in that second file until it's merged back. Copy only app.db and you may be looking at data that's hours or days old.

Working on a copy is the simplest safety net, whichever tool you use below.

1. The sqlite3 command line, in read-only mode

If you have the sqlite3 program installed (it ships with macOS and most Linux systems), open the file read-only:

sqlite3 -readonly app.db

Then .tables lists the tables, .schema tablename shows how a table is built, and a normal SELECT * FROM tablename LIMIT 20; shows rows. Add .mode box before your query for a tidier table.

It's free, fast and exact. It's also all text, so scrolling through thousands of rows or comparing columns gets tiring quickly. See the sqlite3 command line docs for more.

2. DB Browser for SQLite

DB Browser for SQLite is a free desktop app for Windows, macOS and Linux. It shows tables in a grid, lets you browse and filter, and can export to CSV. Use Open Database Read Only… from the File menu if you only want to look, so edits can't be saved by accident.

It's a good choice when you work with SQLite often and don't mind installing a separate program.

3. A database IDE

General database tools such as DBeaver also open SQLite files, next to PostgreSQL, MySQL and others. They're powerful, but heavy if all you want is to peek inside one file. Check the connection settings for a read-only option before you start clicking around.

4. Inside VS Code, read-only by default

If you already spend your day in VS Code (or VSCodium, Cursor and other editors that use Open VSX), you can open the database right next to your code. Our free SafeLite: SQLite Viewer extension was made for exactly this:

SafeLite SQLite Viewer showing tables, schema and a paged grid in VS Code

To open a file, right-click a .db, .sqlite, .sqlite3, .db3, .s3db or .sl3 file in the Explorer and choose Open in SafeLite SQLite Viewer.

If you do need to fix a value, you can turn on write mode. You confirm each change after seeing how many rows it affects, and a timestamped backup copy of the file is saved before every write.

It's free on the VS Code Marketplace and Open VSX. More on the SafeLite page.

A few honest limits: it handles files up to 2 GB and needs free memory of roughly the file size. Encrypted databases (such as SQLCipher) are detected but can't be opened, and FTS5 and R*Tree tables show a message instead of rows.

Which one should you use?

Whichever you pick, open read-only first and copy the -wal file along with the database. That covers most "I opened it and now it's different" surprises.

Questions or a file that won't open? Visit our support page.