About the SQL Formatter
The formatter uses the open-source sql-formatter library, which tokenizes and parses each dialect with its own rules. That matters: backtick identifiers are MySQL/MariaDB/BigQuery syntax, [brackets] and TOP are T-SQL, :: casts and dollar-quoted strings are PostgreSQL, QUALIFY is Snowflake/BigQuery. Choosing the matching dialect avoids parse errors and keeps those constructs intact.
Each major clause — SELECT, FROM, JOIN, WHERE, GROUP BY, ORDER BY — starts a new line, select-list columns are placed one per line, and subqueries and CTEs are indented. Keywords sets the case of keywords, data types and built-in functions; identifiers and string literals are never changed. AND/OR on new line first puts logical operators at the start of lines, which makes long WHERE conditions easier to comment out.
Multiple statements separated by ; are formatted one after another. The formatter does not validate table or column names and does not execute anything — it only rearranges whitespace and keyword case, so the query means exactly the same. Comments (-- and /* */) are preserved. Your SQL is processed in the browser, which makes it safe for queries that reveal schema details.
How to use it
- Paste one or more SQL statements.
- Select your database dialect.
- Choose keyword case and indentation.
- Copy or download the formatted query.
Frequently asked questions
Which SQL dialects are supported?
Why do I get a parse error?
TOP 10 with MySQL selected) or the statement uses a templating placeholder like {{ var }}. Switch dialects or replace placeholders with literals.