SQL Formatter
Format and beautify SQL for PostgreSQL, MySQL, SQLite and more.
About this tool
Paste a query, even a long one-liner from a log, and get it laid out one clause per line. Choose the SQL dialect, keyword case and indentation.
How to use it
- Paste a query, for example a long one-liner copied from a log or an ORM debug output.
- Choose your database dialect so its keywords and syntax are recognised.
- Pick keyword case (UPPER, lower or as typed) and indentation, or One line to compact it.
- Copy the formatted query.
Questions
- Which databases are supported?
- Standard SQL, PostgreSQL, MySQL, MariaDB, SQLite, SQL Server (T-SQL), Oracle PL/SQL, BigQuery, Snowflake, Redshift, DuckDB, ClickHouse, Spark SQL and Trino/Presto.
- Does formatting change what the query does?
- No. Only whitespace and, if you choose, the case of keywords change. Identifiers, string literals and the query logic stay exactly as they were.
- Can I format several statements at once?
- Yes. Separate them with semicolons and each statement is formatted on its own, with a blank line in between.
- Is my query sent anywhere?
- No. Formatting runs in your browser, so queries with table names or data from production never leave your machine.
Something not working, or a result looks wrong? Report a problem with this tool