Tidy messy SQL
One-line SQL pasted from a log becomes readable: keywords uppercased, clauses on their own lines, consistent indent.
Tools used in this guide
The job
Queries arrive minified in logs and stack traces. Reformatting makes the structure visible — which JOIN, which WHERE — before you debug or hand it to review.
Format
Paste SQL, pick keyword case and indent width, format or minify. Comments and string literals pass through untouched; the output is the same query with line breaks.
- Major clauses (SELECT/FROM/WHERE/GROUP BY/ORDER BY/JOIN…) each get their own line.
- Minify does the reverse — useful when pasting back into a one-line field.
Worked example
"select u.id, o.total from users u join orders o on o.user_id=u.id where o.total>100" becomes five readable lines — the join condition is suddenly visible.
Where it stops
Cosmetic only — it re-breaks and re-cases text; it does not parse, validate, or optimize. Dialect-specific syntax (hints, LATERAL, arrays) is preserved literally, not understood. Input capped at 512 KB.