SQL Formatter
Drop in a one-liner SQL or a query with broken indentation and get it nicely formatted. The formatter recognizes dialect-specific keywords for clean line breaks and indentation.
How to Use
Paste your SQL query into the left pane or type it directly. Output updates as you type.
Choose the dialect that matches your database (default 'Standard SQL'). Pick keyword case (UPPER / lower / preserve) and indent (2 / 4 / tab).
Click Copy for clipboard, or 'Download .sql' to save the file.
FAQ
How do SQL dialects differ?
MySQL backticks (`), PostgreSQL casts (::), BigQuery STRUCT() — each dialect has unique syntax. Pick the one matching your DB; if unsure, leave as 'Standard SQL (GenericSQL)'.
Are comments preserved?
Yes. Single-line (--) and block (/* */) comments stay as-is, so you can diff cleanly.
Does it handle syntax errors?
Most minor issues are tolerated, but severe errors like mismatched parentheses can produce odd output.
Does it execute the query?
No. This tool only formats text — there's no database connection and no result preview.
Is anything sent to a server?
No. Formatting runs in your browser via the sql-formatter library; your SQL never leaves the page.