SQL Formatter
Format SQL queries with proper line breaks and indentation.
What is the SQL Formatter?
This tool takes a SQL query written on one line or with inconsistent spacing and reformats it with each clause on its own line and consistent indentation, in the style of the SQL dialect you choose — standard SQL, MySQL, PostgreSQL, SQL Server, Oracle or SQLite.
How to use it
- Paste your SQL query into the input box.
- Choose the database dialect you're targeting, since keyword and quoting conventions differ slightly between them.
- Click Format SQL and copy the readable result.
A long query with joins, subqueries and conditions is much easier to review and debug once each SELECT, FROM, WHERE and JOIN clause is on its own line. This is especially useful when reviewing a query generated by an ORM, cleaning up a query before adding it to documentation, or making a complex query easier for a teammate to review in a pull request. This tool is powered by the open-source sql-formatter library, which understands dialect-specific syntax rather than applying one generic style to every database.