SQL Formatter: Beautify SQL Queries for MySQL, PostgreSQL, SQL Server and More

Long queries are much easier to read and review when each clause starts on its own line. Paste any SQL, pick your database and get it formatted with the open-source sql-formatter library: SELECT columns one per line, JOINs and WHERE conditions lined up, keywords in UPPER or lower case. One tap squeezes it back onto a single line.

loading tool

How to use the sql formatter

  1. Paste your code (or tap Try a sample).
  2. Choose the options; the result updates as you type.
  3. Copy the result or download it.

Good to know

  • Upper-case keywords make the structure of a query easy to see at a glance.
  • Formatting does not check that the query is valid: use the SQL Checker for that.

Questions

Which databases are supported?

Standard SQL, MySQL, MariaDB, PostgreSQL, SQL Server (T-SQL), SQLite, Oracle PL/SQL, BigQuery, Snowflake, Redshift, Spark SQL, IBM Db2 and Trino / Presto. Picking yours makes sure its special syntax is understood.

Does the minifier change my data?

No. Comments and extra spaces are removed, but text inside quotes is kept exactly as written.

Is my code uploaded?

No. The open-source library is downloaded once from a public CDN and then runs in your browser. Your code stays on your device.

Is my data private?

Yes. Everything happens inside your own browser: nothing you type or choose is uploaded to us or anyone else.

Is it free?

Completely free, with no sign-up, no watermark and no limit on how many times you use it. Light ads keep the site running.