SQL Formatter
Paste a query, choose your database, and get clean, consistently indented SQL. Nothing is sent to a server.
Formatted SQL
Formatted SQL
Press Format SQL to see the result.
Why format SQL?
Queries copied from logs, ORMs or old reports often arrive as one long line. Putting each clause on its own line, with consistent indentation and keyword case, makes it far easier to see what a query does and to spot mistakes like a missing join condition.
What the formatter does
- Starts each major clause (
SELECT,FROM,WHERE, …) on a new line. - Lists selected columns one per line and indents joins under
FROM. - Applies the keyword case you choose, and leaves your table and column names unchanged.
Formatting only changes whitespace and letter case of keywords, so the query returns exactly the same results. Choose your database in the Dialect menu so database-specific syntax is recognised.
New to SQL? The SQL Syntax lesson covers the style conventions this tool applies. Formatting uses the open-source sql-formatter library.