SQL Formatter
Format MySQL, PostgreSQL and standard SQL.
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
- Paste your SQL into the left pane or open a .sql file.
- Choose your dialect so keywords and functions are recognised correctly.
- Set keywords to UPPERCASE, lowercase or Preserve, and pick a 2 or 4 space indent.
- 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.