SQL Formatter
Turn a one-line or messy SQL query into clean, readable SQL with consistent indentation and keyword case. Choose your dialect, format, and copy.
SQL
Formatted SQL
How to use the SQL Formatter
- Paste a query into the editor, open a .sql file, or press Sample.
- Choose your SQL dialect so dialect-specific syntax is parsed correctly.
- Press Format, or Ctrl + Enter. Use Minify to put it back on one line.
- Copy the output or download it as a .sql file.
Example
select u.id, u.email, count(o.id) as orders from users u left join orders o on o.user_id = u.id where u.created_at >= '2024-01-01' group by u.id, u.email having count(o.id) > 3 order by orders desc limit 20;SELECT
u.id,
u.email,
count(o.id) AS orders
FROM
users u
LEFT JOIN orders o ON o.user_id = u.id
WHERE
u.created_at >= '2024-01-01'
GROUP BY
u.id,
u.email
HAVING
count(o.id) > 3
ORDER BY
orders DESC
LIMIT
20;What it does
- Ten SQL dialects
- Standard SQL, MySQL, MariaDB, PostgreSQL, SQL Server (T-SQL), SQLite, Oracle PL/SQL, BigQuery, Snowflake and Redshift.
- Format, minify and change case
- Beautify a query, compress it to one line, or convert keywords to UPPERCASE or lowercase without touching strings or identifiers.
- A real code editor
- Syntax highlighting, line numbers, search and undo, with a fullscreen mode for long scripts.
- Nothing leaves your browser
- Queries often contain table names, customer data or credentials. This tool never sends them anywhere.
Frequently asked questions
Which SQL dialects are supported?
Standard SQL, MySQL, MariaDB, PostgreSQL, SQL Server (T-SQL), SQLite, Oracle PL/SQL, BigQuery, Snowflake and Amazon Redshift. Each uses its own grammar from the open-source sql-formatter library. Very new or vendor-specific syntax may not be recognised; in that case the tool shows an error instead of guessing.
Does formatting change what my query does?
No. Only whitespace, line breaks and, if you choose, keyword case change. String literals, quoted identifiers and comments are kept exactly as written.
Is my SQL uploaded anywhere?
No. Formatting runs in JavaScript on your device. Your query is not sent to a server, logged, or stored.
Can it format stored procedures and multiple statements?
Yes. Separate statements with semicolons and they are formatted one after another with a blank line between them. Procedural blocks are supported as far as each dialect grammar allows.
What is the difference between formatting and validating?
The formatter must parse your SQL, so it reports serious syntax errors. It does not connect to a database, so it cannot tell you whether a table or column exists.