SQLite to CSV: 4 Easy Ways (No Code Needed)
CSV is the easiest way to get data out of a SQLite database and into something else. Spreadsheets, BI tools, email attachments, other databases: nearly everything reads CSV.
This guide shows four easy ways to convert SQLite to CSV. The first needs no install and no code. The others use tools you may already have. We’ll also cover exporting just part of a table, handling dates, and making sure Excel reads your file correctly.
Method 1: Export to CSV online (no install)
This is the fastest route and works on any device.
- Open our free online SQLite viewer.
- Drop your .db, .sqlite or .sqlite3 file onto the page.
- Click the table you want in the sidebar.
- Click Export CSV.
The CSV downloads right away, named after the table. It includes a header row with the column names.
Your database isn’t uploaded. The conversion happens inside your browser, which makes this safe for private data.
Export only some rows or columns
Often you don’t want the whole table. Use a query instead:
- Open the Run SQL tab.
- Write a query that picks what you need, for example:
SELECT name, email, country
FROM customers
WHERE country = 'Germany'
ORDER BY name;- Run it with Ctrl and Enter.
- Click Export CSV next to the results.
You get a CSV with exactly those rows and columns.
Search, then export
If you’re not comfortable with SQL, you can also type into the search box above a table to filter rows. Then use a query for the final export, since the table export button saves the whole table.
Method 2: Use the sqlite3 command line
The official sqlite3 tool can write CSV directly. It’s built into macOS and easy to install elsewhere. See our Windows and Mac guides for setup.
Open your database:
sqlite3 mydata.dbThen run:
.headers on
.mode csv
.output customers.csv
SELECT * FROM customers;
.output stdoutThis writes customers.csv in the current folder. The last line switches output back to the screen.
For a single export, .once is shorter:
.headers on
.mode csv
.once customers.csv
SELECT * FROM customers;Export in one command
You can skip the interactive shell entirely:
sqlite3 -header -csv mydata.db "SELECT * FROM customers;" > customers.csvThis is handy in scripts and scheduled jobs.
Export every table
To export every table to its own CSV file, loop over the table names in a shell script. On Mac or Linux:
for t in $(sqlite3 mydata.db "SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%';"); do
sqlite3 -header -csv mydata.db "SELECT * FROM \"$t\";" > "$t.csv"
doneMethod 3: DB Browser for SQLite
If you have DB Browser for SQLite installed:
- Open your database.
- Go to File, then Export, then Table(s) as CSV file.
- Pick one or more tables.
- Choose options like the separator and whether to include column names.
- Click Save.
To export a query result, run it in the Execute SQL tab, then use the button to save results as CSV.
Not installed? Our article on DB Browser for SQLite online explains the browser alternative.
Method 4: Python
For developers, Python makes it easy. With only the standard library:
import csv
import sqlite3
con = sqlite3.connect("mydata.db")
cur = con.execute("SELECT * FROM customers")
with open("customers.csv", "w", newline="", encoding="utf-8") as f:
writer = csv.writer(f)
writer.writerow([d[0] for d in cur.description])
writer.writerows(cur)
con.close()With pandas, it’s even shorter:
import sqlite3
import pandas as pd
con = sqlite3.connect("mydata.db")
df = pd.read_sql_query("SELECT * FROM customers", con)
df.to_csv("customers.csv", index=False)
con.close()Which method should you use?
| Situation | Best method |
|---|---|
| One-off export, any device | Online viewer |
| Need part of a table | Online viewer with a query |
| Automated or scheduled exports | sqlite3 command line |
| Export many tables with a GUI | DB Browser for SQLite |
| Part of a data pipeline | Python |
Getting CSV into Excel without problems
Excel is picky about CSV files. Here are the common issues and fixes.
Accents and special characters look wrong
Excel sometimes guesses the wrong text encoding. Characters like é, ü or ñ turn into odd symbols. The fix is a small marker at the start of the file called a byte order mark. Our viewer adds it automatically, so Excel reads the file as UTF-8.
If you export with other tools, open the CSV in Excel using Data, then From Text/CSV, and choose 65001: Unicode (UTF-8) as the file origin.
Leading zeros disappear
Excel converts “00123” to 123. For phone numbers and ZIP codes, import with From Text/CSV and set that column to Text.
Long numbers turn into scientific notation
Excel shows long IDs like 1234567890123456789 as 1.23457E+18, and only keeps 15 significant digits. Import the column as Text to keep the full value.
Dates show as numbers
SQLite often stores dates as numbers. Convert them in your query before exporting:
SELECT id, datetime(created_at, 'unixepoch') AS created
FROM orders;For more Excel tips, read our full guide to converting SQLite to Excel.
Exporting common app databases to CSV
A lot of people want CSV exports from databases they found inside apps. Here are quick queries for a few popular ones. Paste them into the Run SQL tab, then click Export CSV.
Chrome browsing history
SELECT url, title, visit_count,
datetime(last_visit_time / 1000000 - 11644473600, 'unixepoch') AS last_visit
FROM urls
ORDER BY last_visit_time DESC;Chrome counts time in microseconds since 1601, which is why the formula looks odd. Our Chrome history guide explains it.
Android text messages (mmssms.db)
SELECT address, body, datetime(date / 1000, 'unixepoch') AS sent
FROM sms
ORDER BY date DESC;Django users
SELECT id, username, email, date_joined FROM auth_user;Password hashes live in the same table. Leave that column out when you share a CSV.
Choosing a separator
Most tools use a comma. Some regions, including much of Europe, use a comma as the decimal mark, so Excel there expects a semicolon between columns. If your CSV opens with everything in one column, that’s the reason.
You have two easy fixes:
- In Excel, use Data, then From Text/CSV, and pick Comma as the delimiter.
- With the sqlite3 command line, set a different separator before exporting. Use
.mode listand.separator ";"for semicolons. Keep in mind this simple mode doesn’t add quotes around values, so it’s best for clean data without semicolons inside text.
Keeping exports private
A CSV is plain text. Anyone who gets the file can read it. Before sending an export:
- Remove columns you don’t need, especially emails, phone numbers and password hashes.
- Filter rows to the smallest set that answers the question.
- Name the file clearly so it doesn’t get mixed up with other exports.
A short query that selects only the right columns is the easiest way to do all three.
Handling tricky data
- Commas and quotes in text: proper CSV wraps these values in double quotes. All four methods above handle this correctly.
- Line breaks in text: also wrapped in quotes. Some older tools struggle with them, but Excel and Google Sheets handle them fine.
- NULL values: these become empty cells.
- BLOB columns: binary data doesn’t fit CSV well. Our viewer writes BLOBs as hex text. It’s usually better to leave BLOB columns out of your query.
CSV vs other export formats
CSV isn’t always the best choice. A quick comparison:
| Format | Good for | Watch out for |
|---|---|---|
| CSV | Spreadsheets, imports, sharing | No data types, one table per file |
| JSON | Web apps and code | Bigger files, not spreadsheet friendly |
| SQL dump | Moving data to another database | Needs a database to read it |
| .db copy | Keeping everything together | Needs a SQLite viewer to open |
If the person receiving the data will open it in Excel or Google Sheets, CSV is the right pick. If a developer will load it into code, JSON may be easier. Our viewer exports both with one click.
Want the technical detail? See the official SQLite command-line shell documentation.
Frequently asked questions
Can I convert SQLite to CSV without installing anything?
Yes. Use our online SQLite viewer. Open the file, pick a table, and click Export CSV.
How do I export all tables at once?
Use the shell loop shown above, or DB Browser for SQLite, which lets you pick several tables. In the online viewer, export each table separately.
Is there a size limit?
In the browser viewer, the whole database must fit in memory. A few hundred megabytes works on most laptops. The command line has no practical limit.
Can I export a view?
Yes. Views work like tables. Click the view in the sidebar and export it, or select from it in a query.
Summary
To convert SQLite to CSV, the quickest way is to open the file in our free SQLite viewer and click Export CSV. Use a query first if you only need some rows or columns. For automation, the sqlite3 command line exports with one command. DB Browser for SQLite and Python are great options too. Convert dates in your query, and use UTF-8 import settings if Excel shows odd characters. If you’re new to SQLite, start with how to open a SQLite file.







