About this SQL formatter and beautifier
Make long, single-line SQL queries readable. This SQL beautifier puts each clause (SELECT, FROM, JOIN, WHERE, GROUP BY, HAVING, ORDER BY) on its own line, indents subqueries, CTEs and CASE expressions, aligns conditions under WHERE and AND, and can uppercase keywords. It works with SQL Server (T-SQL), PostgreSQL, MySQL, SQLite, Oracle and Snowflake syntax, and is handy for tidying queries copied from logs, ORMs such as Entity Framework, Hibernate or Dapper, or stored-procedure dumps before a code review.
How to use the SQL Formatter
- Paste your SQL query, stored procedure or ORM-generated statement.
- Choose indent size (2 or 4 spaces) and whether keywords should be uppercased.
- Click Format and copy the result, or Minify to collapse it back to one line.
Example
select u.id,u.name,count(o.id) 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 3 desc → SELECT u.id, u.name, COUNT(o.id) 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 3 DESC
Frequently asked questions
Which SQL dialects are supported?
The formatter is dialect-agnostic and handles standard SQL plus common syntax from T-SQL, PostgreSQL, MySQL and Oracle, including [bracketed], `backticked` and "double-quoted" identifiers, TOP and LIMIT, CTEs (WITH), window functions and MERGE statements.
Will it change my query logic?
No. Only whitespace and keyword casing change; string literals, comments, identifiers and parameter names (@p0, :id, ?) are preserved exactly, so the formatted query returns identical results.
How do I format SQL in SQL Server Management Studio or Azure Data Studio?
SSMS has no built-in formatter and Azure Data Studio only offers basic indentation, which is why many people paste queries here. Format the query, then paste it back into the editor.
How do I format SQL in VS Code or Visual Studio?
Both IDEs need an extension for SQL formatting. If you only need to tidy a query occasionally, this online SQL formatter is faster than installing and configuring one.
Can I format a very large SQL file?
Yes. Formatting happens in your browser, so there is no upload size limit; files of several megabytes format in a second or two.
Does it uppercase keywords like SELECT and WHERE?
Yes, keyword casing is a toggle. Turn it off to keep lowercase keywords, which is the convention in many PostgreSQL and MySQL code bases.
Can it minify SQL as well as beautify it?
Yes. Minify removes line breaks and redundant spaces, which is useful when embedding a query in a string literal or log message.
Is my data safe?
Yes. The tool runs entirely in your browser using WebAssembly. Nothing you type or upload is sent to a server, logged or stored.
Is it free?
Yes, completely free with no sign-up, no limits and no watermarks. It also works offline once the page has loaded.