SQLite File Inspector

Drop a .sqlite or .db file to see page size, encoding, WAL mode, exact per-table row counts, indexes, views and freelist waste. Nothing is uploaded.

The interactive tool loads here when JavaScript runs.

About this tool

What is the SQLite File Inspector?

Drop a .sqlite, .db or .sqlite3 file, the app database from a phone backup, a browser profile, a Rails or Django dev database, and this tool reads it straight from the file format: the 100-byte header's facts (page size, encoding, journal mode, which SQLite version last wrote it), every table, index, view and trigger with its CREATE SQL, and an exact row count per table from walking each table's B-tree page by page, not an estimate.

The honesty notes are part of the output. A database in WAL mode may have committed changes still sitting in its -wal sidecar file, so the counts say they exclude anything not yet checkpointed. WITHOUT ROWID tables store their rows in an index B-tree the table walk does not cover, so they are reported as not counted rather than shown as a false zero. And freelist pages, space from deleted rows that SQLite keeps for reuse, are priced in bytes with the note that VACUUM returns them to the filesystem.

Everything is read by JavaScript in this tab, implemented from the file-format document at sqlite.org. The database is never uploaded, which matters because these files are usually someone's messages, browsing history or customer records.

  • Header facts: page size and count, encoding, journal mode, schema format, user_version, application_id, writing SQLite version
  • Exact per-table row counts from walking each table B-tree, cross-checked in tests against sqlite3
  • WITHOUT ROWID tables reported as not counted, never as zero
  • WAL-mode caveat on every count; -wal sidecar files recognised and named
  • Indexes, views and triggers with their CREATE SQL
  • Freelist pages priced in bytes with the VACUUM note
  • Runs entirely in your browser; the database is never uploaded
Read the guide: How to Read HAR Files, GC Logs and SQLite Databases

Updated

How to use the SQLite File Inspector

  1. Find the file: app databases end in .db, .sqlite or .sqlite3; browsers and phones keep dozens. If there is a -wal file next to it, the pair belongs together; copy both and checkpoint, or expect the counts to lag the latest commits.
  2. Drop the file on the page, or press Load a sample to inspect a small example database first.
  3. Read the header facts: file size, pages, page size, encoding, journal mode and the SQLite version that last wrote the file.
  4. Check the tables: exact rows and pages per table, sorted largest first, each with its CREATE SQL, then the indexes, views and triggers below.
  5. Mind the notices: the WAL caveat when it applies, and the freelist figure that says how much of the file VACUUM would give back.

Worked examples

Exact counts, cross-checked against sqlite3

Input

The test-suite fixture: a 72 KiB database written by sqlite3 3.51.0 with a users and an orders table

Output

tables (2) · 2,000 rows in all: orders 1,500 rows (7 pages), users 500 rows (5 pages)

The counts come from walking the B-trees, and the test suite asserts they equal SELECT COUNT(*) from sqlite3 itself on the same file. Pages per table also hint at row width: 1,500 small orders fit in 7 pages of 4 KiB.

A WAL-mode database says what it cannot see

Input

A fixture written in WAL mode (header bytes 18 and 19 are 2)

Output

WAL mode flagged, with the caveat: row counts exclude changes not yet checkpointed from the -wal file

Committed rows can sit in the -wal sidecar until a checkpoint. Without the caveat the count would simply be wrong for a live database; with it, you know to checkpoint first when the latest rows matter.

WITHOUT ROWID is not counted, and says so

Input

The same fixture's kv table, declared WITHOUT ROWID

Output

kv: not counted (WITHOUT ROWID)

The file format stores WITHOUT ROWID tables as index B-trees, a different page layout from the table walk this tool does. Reporting "not counted" is honest; reporting 0 would be a lie the test suite exists to prevent.

Freelist waste, priced

Input

The WAL fixture after deleting 160 of its 200 log rows

Output

freelist: 82 pages (41.0 KiB) reusable — VACUUM would return them

Deletes freed 82 of the file's 107 pages but the file did not shrink; SQLite keeps the pages for reuse. On a 40 GB production file the same mechanism is why disk usage never falls after a cleanup until VACUUM runs.

Background and insight

An SQLite database is one file with a 100-byte header, and the header alone answers several questions sqlite3 is usually opened for. The page size lives at offset 16 (a power of two from 512 to 32768, or the value 1 meaning 65536); offsets 18 and 19 hold the journal mode, 1 for rollback journalling and 2 for WAL; offset 56 names the text encoding; offset 36 counts the freelist pages; and offset 96 records the SQLITE_VERSION_NUMBER of the library that last modified the file, which is how this tool can say "written by SQLite 3.51.0".

The schema itself is a table: page 1 is always the root of the sqlite_schema B-tree, whose rows hold each object's type, name, owning table, root page and CREATE SQL. From each table's root page, the inspector walks interior pages (type 5) down to leaf pages (type 13) and sums the cell counts, which is why the row counts are exact for the file as it is on disk; the test suite cross-checks them against sqlite3's own COUNT(*) on the same file. WITHOUT ROWID tables are the documented exception: the format stores them as index B-trees (types 2 and 10), so they are named and excluded from counting.

Two caveats come from how SQLite writes. In WAL mode, a commit appends to the -wal file and leaves the main file untouched until a checkpoint copies the changes back (by default once the WAL reaches 1000 pages), so a tool reading only the main file sees the last checkpoint, not necessarily the last commit. And deleted data does not shrink the file: freed pages go on the freelist for reuse, and only VACUUM, which the SQLite documentation describes as rebuilding and repacking the file, returns that space, at the cost of up to twice the file size in temporary disk.

Common use cases

  • An unknown .db file from a backup or export

    Drop it and the schema tells you what app it belongs to and what is inside, without installing sqlite3 or risking an upload of someone's personal data.

  • A mobile app database that keeps growing

    The per-table pages and the freelist figure show whether the growth is rows, one bloated table, or dead space a VACUUM would reclaim.

  • "Why are my latest rows missing?"

    If the file is WAL mode and was copied without its -wal sidecar, the newest commits are in the file you did not copy; the WAL flag plus caveat diagnoses this in one glance.

  • Verifying a data migration

    Exact per-table row counts on the before and after files are the cheapest migration check there is, and the copyable summary diffs cleanly.

  • Reviewing schema in a pull request or incident

    Every index, view and trigger is listed with its SQL, so "did anything create a trigger on this table" is answered without a query console.

Tips and limitations

  • Copy a WAL-mode database together with its -wal file: SQLite's documentation warns that separating them can lose committed transactions or corrupt the database. Drop a -wal file here and the tool names it rather than misreading it.
  • The in-header database size (and so the page count shown) is what the header records; on files written by very old SQLite versions it can lag the true file size, which is why the file size is shown next to it.
  • A big freelist is not an error, it is deferred reuse. Run VACUUM when the dead space matters: it rebuilds the file, needs up to twice the size in free disk, and can change rowids of tables without an INTEGER PRIMARY KEY.
  • The user_version and application_id header fields show up as chips when set; apps use them for schema migrations and file identification, so they often date the file's schema generation.
  • Encrypted databases (SQLCipher and similar) do not start with the "SQLite format 3" magic and are refused by name; this tool cannot and does not try to decrypt.
  • To query the data rather than inspect the file, open it with the sqlite3 CLI; this page answers the file-level questions that otherwise need PRAGMA page_size, page_count, freelist_count, journal_mode and a round of COUNT(*) queries.

Sources and further reading

  1. Database File Format, SQLite. The 100-byte header, B-tree page types, sqlite_schema, WITHOUT ROWID storage, the freelist
  2. Write-Ahead Logging, SQLite. The -wal sidecar, checkpointing, and why the pair must stay together
  3. VACUUM, SQLite. What VACUUM rebuilds, its disk requirement, and the rowid caveat

Frequently asked questions

Is it safe to inspect a database file in the browser?

This page reads the file with local JavaScript and transmits nothing, which is the point: app databases hold messages, history and customer records. Closing the tab discards everything. The caution to keep is about the file itself; treat it as sensitive wherever it goes next.

How exact are the row counts?

Exact for the file on disk: the tool walks every page of each table's B-tree and sums the cells, the same answer SELECT COUNT(*) gives, and the test suite asserts that equality against sqlite3 on the fixture files. The two honest exceptions are WAL changes not yet checkpointed and WITHOUT ROWID tables, both labelled in the output.

Why might row counts miss my newest data?

WAL mode. A commit first lands in the -wal sidecar, and the main file only catches up at a checkpoint (by default when the WAL reaches 1000 pages, or when the last connection closes cleanly). This tool reads the main file only, says so when the header shows WAL mode, and recognises a dropped -wal file by its magic.

What is a WITHOUT ROWID table and why is it not counted?

A table declared WITHOUT ROWID is stored as an index B-tree keyed on its primary key, per the SQLite file format, a different page layout from ordinary tables. This tool's walk covers table B-trees, so such tables are listed with their SQL and marked not counted instead of showing a wrong number.

What are freelist pages and should I VACUUM?

Pages freed by deletes that SQLite keeps for reuse; the file does not shrink when data is deleted. The tool prices them in bytes. VACUUM rebuilds the file into minimal space, needs up to twice the file size in temporary disk, and can renumber rowids on tables without an INTEGER PRIMARY KEY, so run it deliberately, not habitually.

Can this open encrypted or corrupted databases?

Encrypted files (SQLCipher and similar) lack the plain-text header and are refused with that explanation. For corruption, the header and schema often still read, and a truncated file fails with the page number that fell outside the file, which localises the damage.

Does it read the data in the rows?

It decodes records while reading the schema table, and counts, rather than displays, the rows of your tables. For browsing and querying actual rows, use the sqlite3 CLI or a desktop browser; this tool answers the file-level questions first: what is in here, how big, how stale, how much is dead space.

Is there an in-depth guide to the SQLite File Inspector?

Yes. “How to Read HAR Files, GC Logs and SQLite Databases” covers the background, how it works, common pitfalls and worked examples. Read the full guide.