SQL formatter
Paste SQL to make it readable, or compress it to one line. Choose the dialect your database uses.
About this tool
The formatter puts each clause on its own line and indents joins, conditions and subqueries. Comments are kept. The dialect matters for things like TOP and [names] in SQL Server, :: casts and $1 parameters in PostgreSQL, and back-quoted names in MySQL.
Each database writes query parameters its own way: @from_date in SQL Server, $1 in PostgreSQL, :from_date in Oracle and ? in MySQL and Snowflake. Standard SQL accepts all of them. The example follows the dialect you choose.
Compress puts the query on one line, for example for a connector setting or a JSON string. Text in quotes is not changed, and -- comments become /* */ comments so they do not swallow the rest of the line.
The formatter is not a full syntax check. It reports errors it meets, such as a quote or parenthesis that is not closed, but it does not know your tables or columns.
Shortcut: Ctrl + Enter formats the input.
Found a problem?
Tell us what went wrong. You decide whether your own work is included.
Licences
This tool is built with these third-party libraries:
- SQL Formatter 15.9.0: MIT