Free SQL Formatter
Beautify a messy or minified SQL query into readable, indented SQL, entirely in your browser.
How to format SQL
-
1
Paste your SQL
Paste a minified or inconsistently formatted SQL query into the input box.
-
2
Click "Format →"
The query is reformatted with each clause on its own line and consistent indentation.
-
3
Copy the result
Click "Copy output" to grab the formatted SQL for your code, migration, or query tool.
Example use cases
Reviewing a pull request
Turn a dense one-line query in a diff into something readable before reviewing the logic.
Cleaning up a generated query
Reformat SQL produced by an ORM or query builder so it's easier to debug in a query console.
Documenting a query
Produce a clean, consistently indented version of a query to paste into documentation or a wiki.
Frequently asked questions
What does this formatter do?
It breaks a SQL statement onto multiple lines around major clauses (SELECT, FROM, WHERE, JOIN, GROUP BY, ORDER BY, etc.), indents nested parts, and optionally uppercases keywords, to make dense or minified queries easier to read.
Does it validate my SQL or run it?
No. This is a formatter only — it doesn't check your SQL against a database schema or execute it, so it will reformat invalid SQL without necessarily catching the error.
Does it support every SQL dialect?
It uses general-purpose keyword and clause rules that work well for common ANSI SQL, MySQL, PostgreSQL, and SQL Server queries, but very dialect-specific syntax may not always break exactly where you'd expect.
Is my SQL uploaded anywhere?
No. Formatting happens locally in your browser using JavaScript — nothing you paste is sent to a server.