SQL Formatter

Format MySQL, PostgreSQL and standard SQL.

No upload

Loading tool…

Processing happens on your device using your browser's CPU/GPU. Results are kept only in this tab's memory and are wiped when you click “Clear” or close the page.

About SQL Formatter

Paste a query that has grown into one impossible line and get it back properly indented, with keywords aligned and joins on their own lines. Pick the dialect you actually use, from MySQL and PostgreSQL to SQL Server, Oracle PL/SQL, SQLite, MariaDB and BigQuery. It is for developers reviewing someone else's query, analysts tidying a report, and students learning to read SQL. Formatting happens in your browser.

How to use SQL Formatter

  1. Paste your SQL into the left pane or open a .sql file.
  2. Choose your dialect so keywords and functions are recognised correctly.
  3. Set keywords to UPPERCASE, lowercase or Preserve, and pick a 2 or 4 space indent.
  4. Click Format SQL, then copy the result or download it as query.sql.

What people use it for

  • Making a long reporting query readable before a code review or a pull request
  • Cleaning up SQL copied out of an application log or an ORM's debug output
  • Formatting a stored procedure so a teammate can follow the joins and conditions
  • Helping students see the structure of SELECT, JOIN, WHERE and GROUP BY clauses

Good to know

This is a formatter, not a database client. It never connects anywhere, does not run the query and cannot tell you whether a table or column exists. Syntax it cannot parse comes back with a short message instead of a reformatted query. Multiple statements separated by semicolons are formatted and spaced apart. Comments are preserved.

Frequently asked questions

Does it run or validate my query?
No. It only re-indents and re-cases the text. A query that formats cleanly can still fail against a real database, and no connection of any kind is made.
Is it safe to paste a query with real table and column names?
Yes. The SQL is formatted by JavaScript in your browser and is never transmitted or logged. Still, avoid pasting literal passwords or keys into any tool.
Which dialect should I choose?
The one your database uses, so dialect-specific keywords and functions are handled properly. Standard SQL is a safe default if you are unsure or writing portable queries.
Will it change my query's meaning?
No. Only whitespace, line breaks and keyword casing change. String literals and identifiers are left exactly as you typed them.