SQL Formatter and Minifier

Dialect
Output
Indent
Keyword case
Commas
Between queries
Nothing to format yet. Paste a query or try the sample.

About the SQL Formatter

Queries copied from logs, ORMs or old scripts often arrive on one long line. This tool lays them out so you can read them: one clause per line, nested queries indented, long lists split up. It can also do the reverse and squeeze a query onto as few lines as possible.

Pick the dialect that matches your database, then choose the indentation, whether keywords are upper case, lower case or left alone, whether commas go at the end or the start of each line, and how many blank lines separate queries. If the query cannot be read, you see the line and column where it stopped. Everything runs in your browser.

How to format SQL

  1. Paste your SQL or upload a .sql file.
  2. Choose the dialect of your database.
  3. Pick Format or Minify and set the indentation, keyword case and comma position.
  4. Copy the result or download it as a .sql file.

Frequently asked questions

How do I format SQL online?

Paste your query into the Input box, pick the dialect that matches your database and the result appears in the Output box as you type. Choose the indentation, keyword case and comma position, then copy it or download it as a .sql file.

Which SQL dialects are supported?

Standard SQL, MySQL, PostgreSQL, SQLite, SQL Server (T-SQL) and BigQuery. The dialect decides which keywords, quote styles and comment styles are understood, so pick the one your query was written for.

What does minify do to my SQL?

It removes comments and extra whitespace so the query sits on as few lines as possible. Text inside strings and quoted names is left exactly as written.

Does formatting change what my query does?

No. Only whitespace, line breaks and the case of keywords change. Table names, column names, strings and values are not touched, and comments are kept when you format.

Why do I get a parse error on valid SQL?

The formatter reads your query with the rules of one dialect. If it uses syntax from a different database, choose that dialect. The error shows the line and column where reading stopped, and the Go to error button jumps to it.

Is my SQL uploaded anywhere?

No. Formatting runs in your browser and your queries never leave your device.