SQL Formatter
SELECT id, name, email FROM users u JOIN orders o ON o.user_id = u.id WHERE u.age >= 18 AND o.status = 'paid' ORDER BY o.created_at desc LIMIT 20;
Related external sites
Some links are affiliate links.
Related tools
Paste a cramped, one-line SQL query and get it back neatly formatted — major clauses on their own lines, columns indented, and keywords uppercased. It makes queries far easier to read and review. Everything runs in your browser; your SQL is never uploaded.
How to use
- Paste your SQL query into the input box.
- Choose whether to uppercase keywords.
- Copy the formatted result.
How it works
The query is broken into tokens — keywords, identifiers, strings and punctuation. Major clauses like SELECT, FROM, WHERE, JOIN and ORDER BY start on new lines, columns after a comma wrap with indentation, and connectors like AND, OR and ON are indented under their clause. String literals are left untouched and line comments are removed.
Features
Clause line breaks
Major clauses each start on their own line for a clear structure.
Column wrapping
Comma-separated columns wrap with consistent indentation.
Keyword case
Optionally uppercase SQL keywords for a conventional look.
Fully local
Formatting happens in your browser and your SQL is never uploaded.
When to use it
Read logged SQL
Turn a long single-line query from logs into something readable.
Code review
Format queries consistently before reviewing or committing them.
Learning SQL
See the structure of a query laid out clearly clause by clause.
Documentation
Paste clean, formatted SQL into docs, tickets or wikis.
Notes
- This is a general formatter and may not cover every SQL dialect perfectly.
- String literals are preserved exactly; line comments are removed.
- Very complex or nested queries may need minor manual tidying.
- All formatting runs on your device; nothing is uploaded.
FAQ
- Which SQL does it support?
- It handles common SELECT, INSERT, UPDATE and DELETE syntax across most databases. It is a general formatter, not a full dialect-specific parser.
- Do I have to uppercase keywords?
- No. Uppercasing is optional — turn it off to keep keywords in their original case while still applying line breaks and indentation.
- Does it handle dialect-specific syntax?
- Common syntax formats well, but very dialect-specific features may need small manual adjustments afterward.
- What happens with broken SQL?
- It formats the text as best it can without validating it, so a syntactically invalid query is reformatted but not corrected.
- Is my SQL sent to a server?
- No. Formatting happens entirely in your browser and nothing is uploaded.