Skip to content
FreeToUse

SQL Formatter & Beautifier — Free

Format messy SQL queries into clean, readable code. Supports MySQL, PostgreSQL, SQL Server, SQLite and more. Free and private.

Runs in your browser. Nothing you enter is sent anywhere.

About SQL Formatter

Long SQL queries copied from logs or ORMs are hard to read. Paste a query and get neatly indented SQL with consistent keyword casing, making it easier to review, debug and share.

How to use SQL Formatter

  1. Paste your SQL query into the input box.
  2. Choose your SQL dialect, such as MySQL or PostgreSQL.
  3. Choose the indentation and keyword case.
  4. Click "Format SQL", then copy or download the result.

Tips

  • Choosing the correct dialect helps the formatter understand special syntax such as backticks or square brackets.
  • Upper-case keywords make it easier to tell SQL commands apart from table and column names.
  • Formatted queries are much easier to review in pull requests and to compare with the Text Diff tool.
  • Format queries copied from application logs before debugging them; nested subqueries become far easier to follow.

Why format SQL

A query on one long line hides mistakes. With one clause per line and consistent indentation, a missing join condition, a filter in the wrong place or an unexpected subquery stands out at once. Formatted SQL also produces cleaner changes in version control, because editing one column touches one line, and it is much easier to discuss in a code review.

Dialects and options

Pick the dialect you write in, since each has its own keywords and quoting rules. Supported dialects are standard SQL, MySQL, MariaDB, PostgreSQL, SQLite, SQL Server, Oracle PL/SQL, BigQuery, Snowflake, Redshift and Spark. Choose the indentation and whether keywords are upper case, lower case or left alone. The tool never connects to a database or runs your query; it only rearranges the text.