Formatting preserves identifiers and aliases. Style suggestions are not database validation. Maximum input: 100,000 characters.

INPUT 0 characters, 0 lines
OUTPUT
Ctrl + Enter

Turning history off also clears saved queries. Shared links contain your SQL; only share queries you intend others to read.

Client-Side Only

SQL formatting happens locally in your browser. Analytics records usage metadata, not SQL text. See our privacy details.

9 Dialects

PostgreSQL, MySQL, SQL Server, BigQuery, SQLite, MariaDB, Redshift, and Snowflake.

Saves Settings

Your indent size, keyword case, and dialect preferences are saved locally between sessions.

Query History

Optionally keeps your last 5 queries in this browser. Turn history off or clear it at any time.

Ctrl+Enter Format
Ctrl+Shift+C Copy
Ctrl+Shift+Backspace Clear
Ctrl+] Indent
? Shortcuts

Free Online SQLite Formatter

This SQLite formatter instantly beautifies your SQLite queries, making them easier to read, debug, and maintain. Simply paste your unformatted query and click Format.

SQLite-Specific Formatting

Our formatter understands SQLite-specific syntax including:

  • Data Types: SQLite's flexible type system (INTEGER, TEXT, REAL, BLOB)
  • Functions: datetime(), date(), time(), strftime(), julianday()
  • UPSERT: ON CONFLICT clause with DO UPDATE/DO NOTHING
  • Virtual Tables: FTS5 full-text search syntax
  • JSON: json_extract(), json_array(), json_object()
  • Window Functions: ROW_NUMBER, RANK, DENSE_RANK over partitions

Why Format SQLite Queries?

SQLite is the most deployed database in the world, found in mobile apps, browsers, and embedded systems. Clean, formatted queries help with:

  • Mobile app development and debugging
  • Electron and desktop application development
  • Browser extension and web app local storage
  • Data analysis and prototyping

Worked examples

Upsert with ON CONFLICT DO UPDATE

SQLite upserts read as one long line until they are broken up. The conflict target and the update list become separate, checkable pieces.

Before

insert into settings (user_id,key,value) values (1,'theme','dark') on conflict(user_id,key) do update set value=excluded.value,updated_at=datetime('now')

After

INSERT INTO
  settings (user_id, KEY, value)
VALUES
  (1, 'theme', 'dark')
ON CONFLICT (user_id, KEY) DO
UPDATE
SET
  value = excluded.value,
  updated_at = datetime('now')

Recursive common table expression

WITH RECURSIVE has a base case and a recursive case joined by UNION ALL. Splitting them apart is the fastest way to spot a missing termination condition.

Before

with recursive tree(id,parent_id,depth) as (select id,parent_id,0 from nodes where parent_id is null union all select n.id,n.parent_id,t.depth+1 from nodes n join tree t on n.parent_id=t.id) select * from tree order by depth,id

After

WITH RECURSIVE
  tree (id, parent_id, depth) AS (
    SELECT
      id,
      parent_id,
      0
    FROM
      nodes
    WHERE
      parent_id IS NULL
    UNION ALL
    SELECT
      n.id,
      n.parent_id,
      t.depth + 1
    FROM
      nodes n
      JOIN tree t ON n.parent_id = t.id
  )
SELECT
  *
FROM
  tree
ORDER BY
  depth,
  id

Mixed identifier quoting

SQLite accepts double quotes, backticks and square brackets for identifiers. Whichever style you use is preserved rather than normalised.

Before

select "MixedCase",[Bracketed],`Backticked`,count(*) as n from data where "MixedCase" is not null group by "MixedCase",[Bracketed],`Backticked`

After

SELECT
  "MixedCase",
  [Bracketed],
  `Backticked`,
  count(*) AS n
FROM
  data
WHERE
  "MixedCase" IS NOT NULL
GROUP BY
  "MixedCase",
  [Bracketed],
  `Backticked`

Other SQL Dialects

Need to format SQL for other databases? Try our formatters for PostgreSQL, MySQL, SQL Server, or BigQuery.

PostgreSQL MySQL SQL Server BigQuery SQLite MariaDB Redshift Snowflake