SafeLite: SQLite Viewer
A safe, read-only-by-default SQLite browser for large databases.
Browse SQLite databases in VS Code without risking your data. The viewer is read-only by default. It opens databases of hundreds of MB in well under a second, pages through millions of rows instantly, and needs no native modules, so it runs on every platform VS Code runs on.
Measured on a 214 MB database with 1.2 million rows, in VS Code 1.95.3:
- Opens in under a second (0.3-0.75 s across two runs), with the first table already on screen. Switching to the 1.2-million-row table takes about 0.3 s.
- Any page, including the last one, in 1-2 ms. The average of 50 random jumps was 1 ms.
- Sort 1.2 million rows on an unindexed text column in about 2 s, or on a number column in about 1 s. Afterwards, scrolling the sorted view stays instant.
- Filter in about 0.45 s, and search in about 1.1 s.
- SELECT with GROUP BY over all rows in about 0.7 s.
Features
- Read-only by default. The file is opened with SQLite's
query_only switch on, and the extension never writes to it. Tests check this with a SHA-256 hash of the file before and after a full session.
- Tables and views in a side list, including
WITHOUT ROWID, virtual and internal tables.
- Schema panel: columns (type, primary key, NOT NULL, default, hidden and generated), indexes (columns, sort order, unique, origin, partial), foreign keys (with ON UPDATE / ON DELETE), triggers, and the CREATE statement.
- Virtualized, paged grid. Only the rows on screen are fetched. Whole tables are never loaded into the grid.
- Run SQL: SELECT, WITH, VALUES, PRAGMA and EXPLAIN. SELECT results are paged, sortable and filterable like a table.
- Export to CSV: all rows of the current table, view or query result, with your sort and filter applied (RFC 4180 quoting, UTF-8).
- Sort by clicking a column header (ascending, descending, off).
- Filter one column or all columns. You can type text to match (contains), or use
=5, >10, <=2024-01-01, !=x, null or !null.
- Search with Find next, and jump to row.
- Cell details: double-click a cell to see the full text, or a hex dump for BLOBs. Integers above 2^53 are shown exactly.
- Integrity check (quick check) with one click.
- WAL databases: committed changes in the
-wal file are applied in memory, so you see the latest data. The -wal and main files are never changed. Half-written or uncommitted WAL frames are ignored, the same way SQLite ignores them.
- Clear errors for files that are encrypted (for example SQLCipher), compressed (ZIP or gzip), not SQLite, SQLite 2, corrupt or truncated, locked by another program, or larger than 2 GB. Tables that need a module this build does not include (FTS5, R*Tree) show a clear message, and the other tables still open.
- No telemetry and no network access. SQLite runs as WebAssembly (sql.js) inside the extension.
Optional write mode
Write mode is off until you turn it on. Click Write mode… in the toolbar, or run SafeLite: Toggle write mode (backup before every write), and confirm.
- Every change is first run in a transaction in memory. Then you see how many rows it changes, and you confirm it.
- Before every write, a timestamped backup copy of the file is saved (for example
shop.backup-20261018-121530-123.db). It goes next to the file, or into the folder set in sqliteViewer.backupDirectory. Only after that is the new file written. It is written to a temporary file and then renamed into place, so a crash cannot leave a half-written database.
- You can edit a cell (double-click it, then Edit value…) or run INSERT, UPDATE, DELETE or DDL statements in the SQL box.
- Writing is refused if the file changed on disk since it was opened, or if a non-empty
-wal or -journal file shows that another program is using the database.
- WAL-mode databases stay in WAL mode after a write.
Memory: what to expect
sql.js keeps the whole database file in memory while it is open. That is the cost of having no native modules. Measured RSS of the VS Code extension host:
| Database |
After open |
After opening the 1.2M/4.8M-row table |
During a text sort |
After closing the tab |
| 214 MB, 1.2M rows (in VS Code 1.95.3) |
+244 MB |
+285 MB |
+447 MB |
back to baseline (+4 MB) |
| 839 MB, 4.8M rows (engine benchmark, Node 22) |
+853 MB |
+1,054 MB |
+1,429 MB |
+58 MB |
Rule of thumb: you need free RAM of about 1.1× the file size to browse, and up to about 1.7× the file size while sorting a large table on an unindexed column. The sorted row order costs 8 bytes per row. Each open database runs in its own worker thread, so long queries never freeze VS Code, and closing the tab frees all of the memory. You are asked to confirm before opening a file larger than sqliteViewer.confirmAboveMB (1024 MB by default). Files over 2 GB are not supported.
How to open a database
SafeLite does not take over database files by default. Right-click a .db, .sqlite, .sqlite3, .db3, .s3db or .sl3 file and choose Open in SafeLite SQLite Viewer, run SafeLite: Open in SafeLite SQLite Viewer, or use Reopen Editor With... > SafeLite: SQLite Viewer.
To make it the default for .db files, add this to your settings:
"workbench.editorAssociations": { "*.db": "digivibetech.sqliteViewer" }
Settings
sqliteViewer.backupDirectory: the folder for backup copies. Empty means next to the database.
sqliteViewer.confirmAboveMB: ask before opening files larger than this. The default is 1024.
Limits
- Files up to 2 GB. Memory use is about the file size (see above).
- Encrypted databases (SQLCipher, SEE) are detected but cannot be opened.
- A rollback journal left by a crashed writer is not replayed. You see the main file as it is, with a warning, and write mode is disabled.
- PRAGMA and EXPLAIN results show at most 10,000 rows. SELECT results are paged without a limit. A SELECT with ORDER BY on a large unindexed result is re-sorted for each page that is fetched.
- Long operations can be stopped with Cancel. This restarts the engine and reopens the file read-only.
- The bundled SQLite (3.54, via sql.js 1.15) includes FTS3/FTS4 and JSON, but not FTS5, R*Tree or loadable extensions.
Privacy
The extension reads only the database you open (plus its -wal file), and it writes only when you turn on write mode and confirm. It makes no network requests and collects nothing. See https://digivibetech.com/privacy/safelite-sqlite-viewer/
Support
https://digivibetech.com/support/ · DigiVibeTech, Amersfoort, the Netherlands
Third-party: sql.js (MIT), SQLite (public domain). Licence text in vendor/LICENSE-sql.js.txt.
Price
Free. Pro features may come later.
| |