SQL Formatter

Format SQL with one clause per line or minify it, with eight dialects to choose from.

Indent
Dialect
Input
Output

Paste a query and press Format or Ctrl+Enter to split it by clause. The sql-formatter library does the work; only its file is downloaded from jsDelivr on first load, and your query stays in the page.

Indentation is 2 spaces, 4 spaces or Tab. Dialects are Standard SQL, MySQL, PostgreSQL, MariaDB, SQLite, SQL Server, Oracle PL/SQL and BigQuery. Turning keyword uppercase off leaves your own casing as it is and does not lowercase anything. Table and column names are never changed.

Minify skips the library: it finds quoted strings first, then removes comments and extra spaces outside them.

SELECT id, name -- name
FROM users
WHERE status = 'active'
  AND age >= 20;

This becomes SELECT id,name FROM users WHERE status='active' AND age>=20;, 73 characters down to 60. Text inside quotes and inside PostgreSQL $$ blocks keeps every space. The space in a - -1 is kept on purpose so it does not turn into a -- comment.

If formatting reports an error, check the dialect: MySQL backticks and SQL Server brackets only parse under their own dialect. Typing does not format automatically. Neither button changes what the query does, but Minify deletes comments.