SQL Formatter
Format your SQL queries for better structure and clarity.
Loading Smart Logic...
Quick Tip
Paste the raw SQL into the input box.
About This Tool
Why use SQL Formatter?
Paste a long single-line query and get it back with each clause on its own line, keywords in upper case, indented conditions and readable function calls. The formatter tokenizes the query first, so commas, keywords and brackets inside quoted strings, quoted identifiers and comments are left untouched.
This is a readability tool, not a linter: it does not check that your SQL is valid or rewrite it for performance. Formatting works for the common dialects — MySQL, PostgreSQL, SQLite and SQL Server — since they share the clause keywords it recognises.
Key Benefits
Strings and comments preserved
A comma inside 'Smith, John' or a keyword inside a comment stays exactly as written.
Multi-word keywords kept together
LEFT JOIN, GROUP BY and INSERT INTO are treated as single clauses instead of being split across lines.
Keywords upper-cased
Standard style that makes the structure of a query obvious at a glance.
How to use SQL Formatter
- 1
Paste the raw SQL into the input box.
- 2
The formatted version appears immediately on the right.
- 3
Check the clause breaks, then copy or download the result.
- 4
Paste it back into your editor, migration file or ticket.
Best use cases
Make a query from an ORM log readable.
Tidy SQL before a code review or a pull request.
Format a query for documentation or a bug report.
Find the clause structure in a query someone else wrote.
SQL Formatter FAQs
Which SQL dialects are supported?
The formatting is dialect-agnostic and works with MySQL, PostgreSQL, SQLite, SQL Server and similar. Very dialect-specific syntax is left as written rather than reformatted.
Does it check my SQL for errors?
No. It only changes layout. An invalid query comes back formatted but still invalid.
Will it change my query's meaning?
No. Only whitespace and keyword capitalisation change; string literals, identifiers and comments are preserved exactly.
Is my query sent anywhere?
No. Formatting happens in your browser, so queries containing schema or customer details stay local.
Related Developer Tools
More free developer tools that work well alongside sql formatter.