Skip to content
Dev

SQL Formatter

SQL formatter. Paste any SQL query and get it formatted with consistent indentation, one clause per line, and keywords in upper or lower case. Choose a dialect such as MySQL, PostgreSQL, SQL Server, or SQLite, then copy the result. It also minifies queries to one line. Formatting runs in your browser, so queries stay private.

Paste a query. Formatting and minifying run in your browser only.

Changes which words count as keywords. Standard SQL, MySQL, PostgreSQL, SQL Server, SQLite, or BigQuery.

Keywords such as SELECT and WHERE change case. Names and quoted text do not.

Status

SQL formatted with Standard SQL and uppercase keywords.

Pretty-printed or minified SQL appears here. Copy uses this text when it is not empty.

How to use

  1. Paste a SQL query into the box.
  2. Choose a dialect: Standard SQL, MySQL, PostgreSQL, SQL Server, SQLite, or BigQuery. Then choose uppercase or lowercase keywords.
  3. Click Format. SELECT, FROM, WHERE, and JOIN each start on their own line.
  4. Click Minify to remove comments and extra spaces and put the query on one line, then copy the result.

How it works

Formatting changes whitespace and keyword case only. Table names, quoted text, and the query logic stay the same. Each clause such as SELECT, FROM, WHERE, and JOIN starts a new line, with two-space indents inside parentheses. Minify removes comments and collapses whitespace outside quotes onto one line. Nothing is uploaded.

Example. select id, name from users where status = 'select' prints SELECT, then id and name on their own lines, then FROM users and WHERE status = 'select'. The quoted word select stays lowercase.

Example. Minify removes the comment in select id /* keep */ from t -- note and leaves SELECT id FROM t.

Dialects change keywords, not your data

Standard SQL, MySQL, PostgreSQL, SQL Server (T-SQL), SQLite, and BigQuery share the common clauses. A dialect adds its own keywords, such as ILIKE in PostgreSQL, TOP in SQL Server, and QUALIFY in BigQuery. Words inside quotes, brackets, backticks, and dollar quotes are copied as you typed them.

Frequently asked questions

How do I format a SQL query?

Paste the query, pick your SQL dialect, and click Format. Each clause such as SELECT, FROM, WHERE, and JOIN moves to its own line with consistent indents.

Which SQL dialects are supported?

Standard SQL, MySQL, PostgreSQL, SQL Server (T-SQL), SQLite, and BigQuery.

Does it change what my query does?

No. Only whitespace and keyword case change; table names, values, and logic stay the same.

Is my SQL sent to a server?

No. Formatting happens locally in your browser.

Can it minify SQL?

Yes. Minify removes extra whitespace and comments to put the query on one line.