SQL Formatter

  • Free forever
  • No sign-up
  • Runs in your browser
Processed on your device

Format long SQL queries into clean, readable code. Supports MySQL, PostgreSQL, SQL Server, Oracle, SQLite and more.

About SQL Formatter

Lays out long or machine-generated SQL with each clause on its own line and subqueries indented, so joins, conditions and ordering are easy to follow in a code review or bug report. It knows eleven dialects, including Standard SQL, MySQL, PostgreSQL, SQL Server, Oracle, BigQuery and Snowflake, handles several queries separated by semicolons and keeps your comments. Keywords can be upper case, lower case or left as typed.

How to use SQL Formatter

  1. Paste your SQL query, or several queries, into the box.
  2. Choose your SQL dialect, such as MySQL, PostgreSQL or SQL Server, so its syntax is understood.
  3. Set Keywords to UPPERCASE, lowercase or Keep as typed, and pick an Indent.
  4. Click Format SQL, then click Copy to paste the tidy query back into your editor.

How your data is handled

Queries are formatted in your browser with the sql-formatter library, loaded from our own site the first time. Your SQL never reaches a database or server, and isn't stored.

How SAA Tool works · Privacy Center

Limits and accuracy

  • MySQL DELIMITER blocks around stored procedures get mangled, so format the procedure body on its own.
  • Keyword case changes SQL keywords only; table and column names stay exactly as typed.
  • SQL built inside quoted strings isn't formatted, because the formatter treats it as plain text.

Questions and answers

Does it run or check my query?

No. It only lays out the text with line breaks and indentation. It never connects to a database, so it can't tell you whether your tables or columns exist.

Why does it say it couldn't format my query?

Part of the query isn't valid for the chosen dialect, for example SQL Server's [square bracket] names when MySQL is selected. Pick the dialect your database uses and try again.

Is my SQL uploaded?

No. Formatting runs in your browser, so queries containing table names or data values aren't sent to SAA Tool.

Do I need to sign up?

No. SQL Formatter is free with no sign-up, no login and no daily limit, and there's nothing to install. It works on a phone as well as a PC.

Does it format PostgreSQL, MySQL and SQL Server syntax?

Yes. Pick the dialect and the formatter understands its keywords and quoting. It only changes layout, so the query runs the same.

Report a problem with this tool