SQL Formatter & Beautifier
This SQL formatter takes a query pasted out of a log file, an ORM dump or a stored procedure and makes it readable: every major clause on its own line, subqueries and parenthesised expressions indented to show their nesting, SELECT lists lined up, and consistent spacing around operators and commas. You can pick the dialect you actually use — MySQL, PostgreSQL, SQL Server, Oracle, SQLite, BigQuery, Snowflake and more — which changes how quoted identifiers, string escapes and dialect-specific keywords are recognised. Keyword case and indent width are yours to set, and everything runs in your browser.
How it works
Puts every major clause on its own line, indents subqueries and parenthesised expressions, lines up the items in a SELECT list, and normalises the spacing around operators and commas — so a query pasted out of a log or a one-line ORM dump becomes readable.
Pick the dialect you actually use. It changes how quoted identifiers, string escapes and dialect-specific keywords are recognised, which matters for backticks in MySQL, square brackets in SQL Server and dollar-quoting in PostgreSQL.
Everything runs in your browser — nothing you paste is sent to a server.
How to format SQL
- Paste your query, stored procedure or script into the input on the left.
- Pick the dialect you actually use — it changes how quoting and escapes are read.
- Copy the formatted result, or download it as a
.sqlfile.
Why the dialect matters
SQL is a family of languages rather than one. The differences that matter most to a formatter are how identifiers
are quoted and how strings escape: MySQL uses backticks, SQL Server uses square brackets, and standard SQL uses
double quotes. PostgreSQL adds dollar-quoted blocks, where a whole function body can sit inside
$$ … $$ and must not be reformatted as if it were part of the surrounding statement.
Choosing the wrong dialect usually still produces readable output, but it can misread a quoted identifier as a string, which changes where line breaks land. If something looks off, the dialect setting is the first thing to check.
What formatting does and does not change
Only whitespace, line breaks and keyword case are touched. String literals and identifiers are left exactly as written, so the query means the same thing afterwards. That also means formatting cannot fix a syntax error — it is a readability tool, not a validator.
One column per line
Long SELECT lists are the usual reason a query is hard to read. Filling them to the line width keeps
the query compact, but breaking them out one per line makes diffs far more useful: adding a column shows as one
added line rather than a whole paragraph rewrapping.
Common use cases
- Reading a query pasted out of a slow-query log or an APM trace.
- Making sense of SQL generated by an ORM before optimising it.
- Standardising formatting across a team before a code review.
Frequently asked questions
How do I format SQL?
Paste your query into the left panel. The formatted version appears on the right immediately, ready to copy or download as a .sql file.
Which SQL dialects are supported?
Standard SQL, MySQL, MariaDB, PostgreSQL, SQLite, SQL Server, Oracle PL/SQL, BigQuery, Snowflake, Redshift, Spark SQL and Db2. The dialect affects how quoted identifiers, escapes and dialect-specific keywords are read.
Does it change what my query does?
No. Formatting only changes whitespace, line breaks and the case of keywords. String literals and identifiers are left exactly as written, so the query means the same thing before and after.
Can I keep my keywords lowercase?
Yes. Choose lowercase, uppercase or as-written from the keyword dropdown — some teams prefer lowercase throughout, and preserving the original is there for when you are formatting someone else’s code.
Can I put every selected column on its own line?
Yes. Tick the one column per line option and the SELECT list is broken out fully rather than filled to the line width, which makes long projections much easier to diff.
Is my query sent to a server?
No. The formatter runs entirely in your browser, so a query containing table names, schema details or real values never leaves your device.
Related tools
SQL Minifier
This SQL minifier strips comments and whitespace to give you a one-line query.
SQL to JSON Converter
This SQL to JSON converter reads INSERT statements and gives you an array of typed records.
SQL Escape / Unescape
This SQL escaper doubles single quotes, with an option for MySQL backslash escapes.