Overview
Introduction
Getting data out of a SQLite database usually means running the sqlite3 CLI or writing a small script. This tool reads simple SQLite files directly in the browser instead, by parsing the file format's own published byte layout.
It's the mirror image of this site's CSV to SQLite Converter, and is scoped the same way: it correctly reads what that tool (or an equivalently simple single-page, TEXT-only, single-table SQLite file) writes, and gives a specific error for anything more complex.
What Is SQLite to CSV Converter?
A SQLite-to-CSV converter that reads the 100-byte database header, walks the sqlite_master schema b-tree on page 1 to find your table's definition and root page, then reads that table's own b-tree leaf page to recover every row.
Each row's SQLite record (a varint-encoded header of serial types, followed by raw column bytes) is decoded back into plain TEXT values and serialized as a CSV row, with column names read back out of the table's stored CREATE TABLE statement where possible.
How SQLite to CSV Converter Works
After confirming the file starts with the "SQLite format 3\0" magic string, the page size and reserved-bytes header fields are read to compute each page's usable size. Page 1's b-tree leaf page is walked cell by cell to find the sqlite_master row for the requested (or first) table, giving its root page number and CREATE TABLE SQL text.
That root page is then walked the same way: each cell's payload-size and rowid varints are read, followed by the record itself, a self-describing header of per-column serial types followed by the raw value bytes, decoded according to SQLite's TEXT/NULL serial-type rules (rejecting any other column type with a specific error).
When To Use SQLite to CSV Converter
Use it to pull data back out of a SQLite database produced by this site's own CSV to SQLite Converter, or another simple, small, single-table SQLite file.
For larger, multi-table, or type-rich SQLite databases, use the sqlite3 CLI or a full SQLite library instead: this tool intentionally doesn't reimplement multi-page b-trees or non-TEXT column types.
Often used alongside CSV to SQLite Converter, PDF to CSV Converter and qCSV to CSV Converter.
Features
Advantages
- No SQLite library, WebAssembly build, or server upload required: the file format is parsed directly with plain byte and varint arithmetic.
- Verified round-trip: a database written by this site's own CSV to SQLite Converter (and independently checked with a real sqlite3 install) reads back to the exact original CSV.
- Gives specific, actionable errors (multi-page b-tree, non-TEXT column, WITHOUT ROWID/index page, unknown table name) instead of silently producing wrong output.
Limitations
- Only single-page tables are supported: a table whose b-tree spans multiple pages (via interior nodes or row overflow pages) is rejected rather than partially read.
- Only TEXT (or NULL) columns are decoded; INTEGER, REAL, and BLOB columns cause a specific unsupported-column-type error.
- Column names are recovered by best-effort parsing of the table's stored CREATE TABLE SQL text; if that SQL doesn't match the simple `"col" TEXT, ...` shape this tool's own writer produces, generic column_N names are used instead (the actual data is still read correctly).
Examples
Best Practices & Notes
Best Practices
- If a database has more than one table, specify the exact table name you want rather than relying on the "first table" default.
- If you hit an error, read it carefully: it names the exact unsupported structure (multi-page b-tree, non-TEXT column, wrong page type) rather than being generic.
- Round-trip your own CSV to SQLite Converter output through this tool to confirm a conversion is lossless before relying on it elsewhere.
Developer Notes
Reading a cell's record requires first reading the SQLite record header's own self-referential length varint, then a varint per column giving that column's serial type, before any column value bytes can be located. This two-pass structure (header, then body) is why `parseRecord` is written as a small generic decoder shared with the sibling CSV to SQLite Converter's schema-row reading, rather than being duplicated per column type.
SQLite to CSV Converter Use Cases
- Exporting data back out of a SQLite database produced by this site's CSV to SQLite Converter
- Quickly inspecting a small SQLite file's contents without installing the sqlite3 CLI
- Verifying a CSV-to-SQLite round trip preserved every row exactly
Common Mistakes
- Trying this on a large, real-world SQLite database (many tables, indexes, INTEGER/REAL columns) and expecting full support: this reader is intentionally scoped to the simple case its sibling writer produces.
- Assuming a parse failure means the file is corrupted; it may simply be a valid SQLite database whose structure (multi-page table, non-TEXT column) falls outside this tool's scope.
Tips
- Leave the table name blank to use the first table found if you're not sure of its exact name.
- Use PRAGMA-based tools like the sqlite3 CLI's `.tables`/`.schema` commands to inspect an unfamiliar database's structure before trying to convert it here.