SQL Formatter
Make long SQL queries readable with clean indentation and consistent keyword case.
How to use the SQL Formatter
- Paste your queryPaste one or more SQL statements, or open a .sql file.
- Choose the stylePick your database dialect, keyword case and indentation, or switch to Minify.
- Copy the resultCopy the formatted SQL or download it as a .sql file.
Example
select id, name from users where active = 1 order by name becomes SELECT, FROM, WHERE and ORDER BY on their own lines, with each column indented.
Minify does the opposite: comments and line breaks are removed and the query fits on one line, with text inside quotes left untouched.
Frequently asked questions
Which databases are supported?
Standard SQL, MySQL, MariaDB, PostgreSQL, SQL Server (T-SQL), SQLite, Oracle PL/SQL, BigQuery, Snowflake, Redshift and Spark SQL. Choosing the right dialect helps with database-specific syntax.
Does formatting change what my query does?
No. Only spaces, line breaks and keyword case change. Table names, values and text inside quotes stay exactly the same.
Why did formatting fail?
The formatter could not understand part of the query, often because of a typo or syntax from another database. Try a different dialect, or check the spot named in the message.
Is my SQL sent to a server?
No. It is formatted entirely in your browser, so it is safe to paste queries that contain real table names.