SQL Formatter & Beautifier
Paste a messy or one-line SQL query to pretty-print it, or minify it to a single line. Pick the SQL dialect, keyword case and indent, then copy or download the result — everything runs locally in your browser.
How to use
- Paste your SQL into the input box, or click Load sample to try a multi-statement example.
- Choose the SQL dialect of your database, the keyword case (preserve, UPPERCASE or lowercase), the indent and the number of blank lines between queries.
- Click Format (or press Ctrl+Enter / ⌘+Enter) to pretty-print the query, or Minify to collapse it to a single line.
- Copy the result to the clipboard or download it as a .sql file.
Example
Input
select u.id, u.name, count(o.id) as orders from users u left join orders o on o.user_id = u.id where u.active = 1 group by u.id, u.name order by orders desc;Output
SELECT
u.id,
u.name,
count(o.id) AS orders
FROM
users u
LEFT JOIN orders o ON o.user_id = u.id
WHERE
u.active = 1
GROUP BY
u.id,
u.name
ORDER BY
orders DESC;Frequently asked questions
Which SQL dialects are supported?
Standard SQL, PostgreSQL, MySQL, MariaDB, SQLite, T-SQL (SQL Server), PL/SQL (Oracle), BigQuery, Snowflake, Redshift and Spark SQL. Choose the dialect of your database so vendor-specific syntax is parsed correctly.
Why do I get a parse error?
The formatter could not understand part of the query in the selected dialect — often an unbalanced quote or parenthesis, or syntax from another database. The message shows the line and column where parsing stopped; fix the query there or switch dialect.
Does formatting change what my query does?
No. Formatting only changes whitespace, line breaks and, if you choose, the case of keywords. String literals, identifiers and the query logic are left unchanged.
Is my SQL sent to a server?
No. Formatting and minifying run entirely in your browser, so you can safely paste queries that contain table names or data from production systems.