SQL Formatter
Make long SQL queries readable with consistent line breaks, indentation and keyword casing. Your code is processed as text in your browser — it is never executed or uploaded.
Loading tool…
Need help with this tool or found a problem? WhatsApp support Email
What does the SQL Formatter do?
The formatter places each major clause (SELECT, FROM, JOIN, WHERE, GROUP BY, HAVING, ORDER BY, LIMIT) on its own line, indents column lists one per line, moves AND/OR conditions onto new lines, and indents subqueries. Strings, quoted identifiers and comments are left untouched.
It works with common dialects including MySQL, PostgreSQL, SQL Server and SQLite for typical SELECT, INSERT, UPDATE and DELETE statements.
How to use the SQL Formatter
- Paste your SQL.
- Choose indentation and keyword case.
- Copy or download the formatted query.
Examples
Report query
A one-line SELECT with joins, filters and grouping becomes a clearly structured query that is easy to review.
Common use cases
- Code reviews
- Debugging queries from logs or ORMs
- Documentation and teaching
Features and benefits
- Private by design — your data is processed on your device and never uploaded.
- Free with no account, no watermark and no usage limits.
- Works on phones, tablets and desktops in any modern browser.
Limitations to know
- Stored procedures and vendor-specific syntax may need manual tidying.
- It formats, but does not validate or run, SQL.
Frequently asked questions
Does it run my query?
No. It only reformats the text.
Which databases are supported?
Standard SQL used by MySQL, PostgreSQL, SQL Server, Oracle and SQLite formats well.
Will it change my data values?
No. Strings and identifiers are preserved exactly.
Related tools
All developer toolsJSON Formatter
Beautify JSON with indentation and syntax error locations.
HTML Formatter
Indent and beautify HTML markup.
JavaScript Beautifier
Re-indent minified or messy JavaScript.
Regex Tester
Test regular expressions with live match highlighting and groups.
CSS Formatter
Beautify minified CSS into readable rules.
URL Encoder
Percent-encode text for safe use in URLs and query strings.