SQL formatter

Format messy SQL into clean, readable queries with each clause on its own line, columns and conditions indented and keywords in capitals. Or minify a query to one line. Works with MySQL, PostgreSQL, SQL Server, SQLite and BigQuery; runs in your browser.

Runs in your browser. Nothing is uploaded.

What the formatter does

  • Starts each clause (SELECT, FROM, JOIN, WHERE, GROUP BY, ORDER BY…) on a new line.
  • Puts each selected column and each AND / OR condition on its own indented line.
  • Indents subqueries and leaves strings, quoted names and comments exactly as they were.

The formatter only changes spacing and keyword case, so your query does exactly the same thing. It doesn't check that the SQL is valid; run it in your database to find errors.

Questions

Is my SQL sent to a server?

No. Formatting happens in your browser, so it's safe for queries that mention internal tables.

Does it change my data or table names?

No. Only SQL keywords change case; names, strings and numbers are left alone.

More free tools