← All Tools
SQL Formatter🔒 100% local
Beautify SQL queries. Privacy-first, no server uploads, no tracking.
Splits a SQL statement at its clause keywords so SELECT, FROM, WHERE and the rest each begin on a new line, and pushes AND/OR conditions in a WHERE or HAVING block onto indented lines of their own. The statement is flattened to one line first and then re-broken. Nothing leaves the page, which matters when the query carries real table or column names.
How to use it
- Paste the statement into the box, or leave the SELECT * FROM users WHERE id=1; example in place.
- Press Process; the re-broken statement appears in the Output panel underneath.
- Read the line breaks: one clause per line, with AND/OR conditions indented four spaces under WHERE or HAVING.
- Press Copy Output to take the result, or Clear to empty both boxes.
Worked example
SELECT * FROM users WHERE id=1;becomesSELECT *
FROM users
WHERE id=1;The statement is flattened before formatting, so any original indentation and line breaks are gone.
SELECT id,name FROM users WHERE a=1 AND b=2becomesSELECT id,name
FROM users
WHERE a=1
AND b=2The WHERE line keeps the first condition on the WHERE line and indents each following AND or OR by four spaces; the first condition keeps a trailing space.
When to use it
- Making a query that was pasted out of a log file or a stack trace readable before you debug it.
- Lining up a long WHERE clause so its AND conditions are easy to scan one at a time.
- Tidying a statement before dropping it into a ticket or a code review comment.
What it does not do
- It is a keyword line-breaker, not a SQL parser. A clause word inside a quoted string still starts a new line: SELECT * FROM t WHERE name='FROM x' comes out as SELECT *, FROM t, and then WHERE name=' and FROM x' split across two lines.
- Flattening collapses runs of whitespace, so -- comments are absorbed into the code around them instead of being kept on their own lines.
- Nothing is validated or colourised. A statement containing none of the recognised keywords, such as DESCRIBE users, comes back exactly as typed.
- Only clause boundaries are split; a long SELECT list stays on one line.