SQL Formatter & Beautifier
Paste a messy or one-line SQL query and get clean, indented SQL in one click. Pick your database, uppercase keywords, or minify it back to one line.
Runs in your browser — your code is never uploaded. Tip: drop a file on the input box, or press Ctrl + Enter.
How to Format SQL
Make any SQL query readable in three steps.
Paste or Upload SQL
Paste your query or upload a .sql file — even one very long line works.
Choose Your Database
Pick MySQL, PostgreSQL, SQL Server, Oracle and more, plus keyword case and indent.
Copy or Download
Copy the formatted SQL or download query.sql. Tick Minify for one line.
Databases
14 SQL dialects
Keywords
UPPER, lower or keep
Minify
One-line SQL
Privacy
Runs in your browser
Works on
Phone & computer
Price
100% free
Before and After
What formatting does to a one-line query.
| Before | After |
|---|---|
select id,name from users where active=1 order by name | SELECT id, nameFROM usersWHERE active = 1ORDER BY name |
| Several queries on one line | Each query on its own block, separated by a blank line |
-- comments | Kept in place (removed when minifying) |
| Text in quotes | Never changed |
What Can You Use It For?
Popular ways people use SQL Beautifier.
Read Long Queries
Understand complex joins and subqueries from logs or ORMs.
Code Reviews
Format SQL before committing so diffs are easy to read.
Documentation
Share clean queries in docs, tickets and Stack Overflow.
Learning SQL
See the structure of SELECT, JOIN, GROUP BY and more.
Tips for the Best Result
-
Choose the right Database — it helps with special syntax like PostgreSQL
::casts or T-SQL[brackets]. - Uppercase keywords make it easy to tell SQL words from table and column names.
- Got an error? Try Standard SQL or check for a missing quote or bracket.
- Compare two versions of a query with Code Compare.
Frequently Asked Questions
Quick answers about SQL Beautifier.
Paste your query and it is formatted instantly. Choose your database and keyword style, then copy or download it.
Standard SQL, MySQL, MariaDB, PostgreSQL, SQLite, SQL Server (T-SQL), Oracle PL/SQL, BigQuery, Redshift, Snowflake, Spark, Hive, DB2 and N1QL.
No. Only spaces, line breaks and keyword case change. Text in quotes and names stay exactly the same.
Yes. Tick Minify (one line) to remove line breaks and comments.
Yes. Separate them with semicolons; each is formatted and separated by a blank line.
Yes, choose the right database (for example T-SQL or PL/SQL). Very unusual syntax may not be supported.
No. Everything runs in your web browser, so your code and data never leave your device.
Yes — 100% free, with no sign-up and no limits.
Related Free Tools
Ready to Use SQL Beautifier?
Scroll up and get your result in seconds. 100% free, no sign-up needed.
Start Now