// free tool

SQLite formatter

Format SQLite in your browser. Every quoting style SQLite accepts, all of its parameter forms and its JSON arrows are read the way SQLite reads them.

Drop a .sql file here to open it. It is read in your browser, not uploaded.

Formatted SQL
CREATE TABLE IF NOT EXISTS notes (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    title TEXT NOT NULL,
    tags TEXT,
    created_at TEXT DEFAULT (DATETIME('now'))
);
INSERT INTO notes (title, tags)
VALUES
    (?1, ?2) ON CONFLICT (id) DO UPDATE SET tags = excluded.tags;
SELECT
    id,
    title,
    tags ->> '$[0]' AS first_tag
FROM
    notes
WHERE
    title LIKE :pattern
ORDER BY
    created_at DESC
LIMIT 20;

Loading the formatter…

Shortcuts in the editor: Ctrl+Enter formats and Ctrl+Shift+Enter minifies (⌘ instead of Ctrl on a Mac). Your settings are remembered in this browser and kept in the page address, so a link shares your style – never your SQL.

What the formatter does with SQLite SQL

  • All three quoting styles. "double quotes", [brackets] and `backticks` are all quoted names, as SQLite allows.
  • Every parameter form. ?, ?1, :name, @name and $name placeholders are each one token.
  • JSON arrows stay whole. -> and ->> (SQLite 3.38 and later) and == are single operators.
  • Blob literals stay literals. x'ff' is kept as one literal instead of being read as a column called x.
  • Schema scripts lay out cleanly. CREATE TABLE IF NOT EXISTS gets one column per line and keeps the table name's case, and ON CONFLICT … DO UPDATE upserts and AUTOINCREMENT get your keyword casing.
  • Quotes come off safely. SQLite names are case-insensitive, so Remove unnecessary quotes can unquote any plain name that is not a keyword.

Examples

SQLite before and after

Before
create table if not exists notes (id integer primary key autoincrement, title text not null, tags text, created_at text default (datetime('now')));
insert into notes (title, tags) values (?1, ?2) on conflict(id) do update set tags=excluded.tags;
select id, title, tags->>'$[0]' as first_tag from notes where title like :pattern order by created_at desc limit 20;
After
CREATE TABLE IF NOT EXISTS notes (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    title TEXT NOT NULL,
    tags TEXT,
    created_at TEXT DEFAULT (DATETIME('now'))
);
INSERT INTO notes (title, tags)
VALUES
    (?1, ?2) ON CONFLICT (id) DO UPDATE SET tags = excluded.tags;
SELECT
    id,
    title,
    tags ->> '$[0]' AS first_tag
FROM
    notes
WHERE
    title LIKE :pattern
ORDER BY
    created_at DESC
LIMIT 20;

The output uses the Standard style with 4-space indents, exactly as the formatter above produces it. Switch the style to Compact for denser SQL or Expanded for leading commas and one item per line. The formatter docs cover the details.

SQLite formatter FAQ

Does it understand SQLite's ?1 and :name parameters?

Yes. ?, ?1, :name, @name and $name are all read as parameters, so they come through the formatter exactly as written.

Can it format a whole schema script?

Yes. Paste or open a .sql file with several statements; each is laid out in turn, CREATE TABLE IF NOT EXISTS bodies get one column per line, and comments stay where they are.

Is my SQL sent to a server?

No. The formatter is compiled to WebAssembly and runs inside your browser tab. Your SQL is never uploaded, logged or stored, and once the page has loaded it keeps working offline.

Can formatting break my query?

It is built not to. After formatting, SQLly checks its output token by token against your input. If anything other than whitespace and the casing you asked for would change, it gives your SQL back exactly as you wrote it and tells you why. SQL that does not parse cleanly, such as an unterminated string, is also left untouched, with the line and column of the problem.

Can I share my formatting settings with my team?

Yes. Every setting, including the advanced ones, is kept in the page address after the # sign, so copying the address or pressing Copy settings link shares your exact style. The link holds the settings only, never your SQL.

// formatting is the least of it

Like the formatter? Meet the rest of SQLly

A native SQL workbench for macOS, Windows and Linux with IntelliSense that knows your schema, guardrails for risky queries, and this formatter built into the editor.