SQL Formatter
← SkillSafe

Format and beautify SQL

Paste a query or open a .sql file. It is formatted as you type, with a free check for common mistakes.

No SQL handy? Try one:

How it works

  1. Paste or open your SQL. One query or a whole script of statements. The database is detected from what only it writes (backticks, square brackets, :: casts, QUALIFY and so on); pick it under Dialect if the guess is wrong.
  2. It is formatted as you type. One clause per line, columns and conditions indented, keywords in the case you choose. Names, strings and numbers are never changed, so the query does exactly what it did before.
  3. Read the check. It points at lines that return wrong rows or run slowly: = NULL that never matches, UPDATE or DELETE without WHERE, joins without ON, LEFT JOINs that a WHERE filter turns into INNER JOINs, NOT IN over a subquery, SELECT *, functions wrapped around filtered columns, GROUP BY 1 and more.
  4. Take it with you. Copy it, copy it as one line for code or a terminal, copy it as a Markdown block for a ticket or pull request, or download a .sql file.

Questions

Is my SQL uploaded?
No. Formatting and the check run inside your browser tab. Only the optional AI rewrite sends your SQL, and only when you press its button.
Which databases does it format?
Standard SQL, PostgreSQL, MySQL, MariaDB, SQL Server (T-SQL), Oracle (PL/SQL), SQLite, BigQuery, Snowflake, Redshift, Spark and Databricks, DuckDB, Trino and Presto, Db2 and Hive. It detects the dialect from the SQL; you can also pick it.
It says it could not read my SQL.
The message names the line and column where it stopped. Usually a bracket or quote is not closed, or the SQL uses syntax of another database: choose yours under Dialect.
Does formatting change what the query does?
No. Only spaces, line breaks and, if you choose, the case of keywords change. Names, strings and numbers stay exactly as you wrote them.
What does the AI rewrite add?
A new version of the query with the problems fixed where SQL alone can fix them, nested subqueries turned into named steps, and clear aliases, plus a list of what changed and whether the results change. It never adds a WHERE you did not ask for, and the page flags any table or column it names that is not in your SQL.