SQLite Formatter & Beautifier
Format and beautify SQLite queries in your browser, including recursive CTEs, UPSERT clauses and ? or :name parameters.
Client-side only, nothing leaves your browser
Formatted SQL will appear here...Formatting SQLite Queries
SQLite SQL often lives inside application code, so it reaches you as a single long string full of ? placeholders. This formatter uses the SQLite dialect of sql-formatter, which accepts "double quotes", `backticks` and [square brackets] around identifiers, plus ?, ?1, :name, @name and $name parameters. Paste the string, get readable SQL back, and nothing is sent to a server.
Supported Features
- Queries: SELECT, INSERT, UPDATE, DELETE, REPLACE
- DDL: CREATE TABLE, CREATE INDEX, CREATE TRIGGER, ALTER TABLE
- SQLite syntax: ON CONFLICT upserts, RETURNING, ? and :name parameters
- Advanced: recursive CTEs, window functions, JSON functions
Formatting Styles
| Style | Description | Example |
|---|---|---|
| Standard | Keywords on new lines, indented clauses | SELECT col FROM table |
| Tabular Left | Keywords left-aligned in column | SELECT col FROM table WHERE x = 1 |
| Tabular Right | Keywords right-aligned in column | SELECT col FROM table WHERE x = 1 |
Frequently asked questions
What does "SQLite format 3" mean?
"SQLite format 3" is the 16-byte header at the start of every SQLite database file, which is why you see it when you open a .db file in a text editor. The rest of the file is binary pages, so you need a SQLite tool to read it. To turn it into readable SQL text, run sqlite3 yourfile.db .dump, or open the file in a database GUI.
Does SQLite have a format function?
SQLite has format(), which works like printf in C: format('%s has %d rows', name, n). It was originally called printf(), and printf() still works as an alias. Use it to build strings inside a query, which is a different job from formatting the layout of SQL code.
How do I format a date in SQLite?
SQLite has no date type, so dates are stored as TEXT, REAL or INTEGER, and you format them with strftime(). strftime('%Y-%m-%d', created_at) works on ISO text dates, and adding the 'unixepoch' modifier converts a Unix timestamp, as in strftime('%Y-%m-%d', 1700000000, 'unixepoch'). The shorter date() and datetime() functions return the common YYYY-MM-DD and YYYY-MM-DD HH:MM:SS forms.
How do I format a number with commas in SQLite?
Add the comma flag to format(): format('%,d', 1234567) returns 1,234,567, and format('%,.2f', 1234567.891) returns 1,234,567.89. The comma flag is a SQLite extension, so the same format string will not work in MySQL or PostgreSQL.
Need a SQLite GUI Client?
1bench is a modern database client for SQLite and 20+ other databases. Query, browse, and manage your data visually.
Learn More