About SQL formatter
Turn a long, one-line SQL query into something you can actually read. The formatter puts each clause on its own line, lines up columns and joins, and indents subqueries, so it is easy to see what a query does and to spot mistakes.
Choose your database so that its own keywords and syntax are understood: MySQL, MariaDB, PostgreSQL, SQL Server (T-SQL), Oracle (PL/SQL), SQLite, BigQuery, Snowflake, Redshift, Spark, DB2 and others. You can also choose whether keywords are written in UPPER or lower case.
How to use it
- Paste your SQL, or open a .sql file.
- Pick your database from the Dialect list. If you are not sure, Standard SQL works for most queries.
- Choose keyword case and indentation. The result updates as you type.
- Copy the formatted SQL or download it as a .sql file.
Several statements at once
You can format a whole script. Each statement separated by a semicolon is formatted on its own, with a blank line between statements. Comments are kept where you wrote them.
If formatting fails
The formatter understands the syntax of the dialect you chose. If it reports an error, check that the right dialect is selected: backtick-quoted names, for example, are MySQL syntax, and square brackets are SQL Server syntax. Template placeholders such as {{name}} or ${value} may also need to be replaced first.
Questions
Does it run my query?
No. It only rearranges the text. Nothing connects to a database, and nothing is sent to a server.
Will formatting change what my query does?
No. Only spacing, line breaks and (if you choose) keyword case change. Table names, strings and values are left exactly as they were.
Which databases are supported?
Standard SQL, MySQL, MariaDB, PostgreSQL, SQL Server (T-SQL), Oracle PL/SQL, SQLite, BigQuery, Snowflake, Redshift, Spark SQL, Hive, Trino/Presto, IBM DB2 and Couchbase N1QL.
Is my SQL private?
Everything happens inside your browser. Your file is never uploaded to a server, so it stays private and the tool keeps working even on a slow connection.