Skip to content
中文
Sign in

SQL Formatter

Format and beautify SQL for MySQL, PostgreSQL, SQLite, T-SQL, BigQuery and more — or minify it back to one line.

FreeRuns in your browserNo sign-up
Dialect
Keyword case
Indent width
Indent style
Options
—
Drop a .sql file here
or click to choose — .sql .txt

SQL in

SQL out

Related tools

Developer tools

How to format SQL

  1. Paste a query — or a whole .sql file — into the left pane, or drop the file onto the box above.
  2. Choose the dialect so that things like backticks, TOP, LIMIT and array syntax are parsed correctly, then set keyword case and indent width.
  3. Press Format and copy or download the result. Minify squeezes the statement back onto one line for a log or a config file.

FAQ

Does my query leave the browser?

No. Formatting runs entirely on this page, so production table names, sample values and credentials in a connection string never reach a server.

Why does the dialect matter?

Each dialect has its own keywords and quoting rules. MySQL uses `backticks`, T-SQL uses [brackets] and TOP n, PostgreSQL has :: casts and $$ bodies, BigQuery allows dotted project names and array literals. Picking the right one keeps those tokens intact instead of breaking them across lines.

Will formatting change what my query does?

No — only whitespace, line breaks and the case of keywords change. String literals, comments, identifiers and values are passed through untouched, so the statement you get back is equivalent to the one you pasted.

Something missing or broken?

Request a tool, report a bug or share a tip with other users.