SQL Formatter Online

Paste a messy SQL query and turn it into readable code with consistent indentation and uppercase keywords. Supports 14 dialects (MySQL, PostgreSQL, SQL Server, Oracle, SQLite, BigQuery…) and can minify too. Your SQL never leaves your browser.

How to format a SQL query

  1. Paste your query into the input panel (several statements separated by semicolons work too).
  2. Pick your database dialect so vendor-specific syntax (MySQL backticks, SQL Server brackets, PostgreSQL operators…) is recognized correctly.
  3. Choose keyword case and indentation, then click "Format SQL".
  4. Copy the result or download it as a .sql file. Use "Minify" when you need the query on a single line.

Why format your SQL?

SQL generated by ORMs, copied from logs or written in a hurry often ends up as one unreadable line. A SQL formatter puts every clause (SELECT, FROM, JOIN, WHERE, GROUP BY, ORDER BY) on its own line and lines up columns and conditions, which makes it much easier to review the logic, spot bugs and do code reviews.

The minifier does the opposite: it strips comments and redundant whitespace while leaving quoted strings untouched — ideal for embedding SQL in code, config files or environment variables.

Frequently asked questions

Which databases does the formatter support?

Standard SQL, MySQL, MariaDB, PostgreSQL, SQL Server (T-SQL), Oracle PL/SQL, SQLite, BigQuery, Snowflake, Redshift, Spark SQL, Hive, Trino/Presto and IBM DB2.

Does formatting change what my query returns?

No. Only whitespace, line breaks and — if you choose — keyword casing change. Table names, column names and string contents are left exactly as they are.

Why do I get an error when formatting?

The formatter has to recognize the dialect syntax. If you use vendor-specific syntax (for example @ or $1 parameters, or proprietary functions), pick the matching dialect. An unclosed quote can also cause it.

Is it safe to paste production queries?

Yes. All formatting happens with JavaScript inside your browser; your SQL is never sent to a server.