About SQL Formatter
The SQL formatter breaks a query onto separate lines at its major keywords — select, from, where, group by, order by and the join variants — so a query that was written as one long line becomes a vertically structured statement you can read.
Queries arrive on one line constantly. They are written in a REPL, logged by an application, or copied out of a monitoring tool, and the resulting single line is technically correct and practically unreadable once it contains more than two clauses. Splitting at keywords restores the shape of the statement.
Keyword matching is case-insensitive, so select, SELECT and Select are all recognised, and the original capitalisation is preserved rather than being normalised. Two limitations are worth knowing: it does not target any particular SQL dialect, and a keyword appearing inside a quoted string will be treated as a keyword.
How to use SQL Formatter
- 1 Paste the SQL statement.
- 2 Each major clause begins on a new line, with the original capitalisation kept.
- 3 Copy the formatted query for review, documentation, or a code review comment.
Frequently asked questions
Which dialect does it target?
None specifically. The keywords it recognises — select, from, where, joins, group by, order by, insert, update, delete and their relatives — are common to essentially every SQL dialect, so the output is useful regardless of which database you use.
Does it uppercase my keywords?
No. The keyword text is left as you wrote it, so a lowercase query stays lowercase. That is a deliberate choice, since opinion on keyword case is divided and silently rewriting someone's style is unwelcome in a review.
What if a keyword appears inside a string literal?
It will be treated as a keyword and given a line break, because the formatter matches on text rather than parsing the statement. The query remains valid — the break falls inside the string — but the layout may look odd, so review any query containing such literals.
Will formatting change what the query does?
No. SQL does not care about line breaks within a statement, so the formatted query is semantically identical. Only the presentation changes, which is what makes this safe to apply to a query you are about to run.
Free, online, and private
Free to use
SQL Formatter is completely free. There is no account to create, no login, and no hidden charge or usage limit.
Runs online in your browser
It is a free online tool that runs entirely in your browser. Nothing to download or install — open the page and start using it right away.
Your data stays private
All processing happens locally on your device. Your input is never uploaded, stored, or tracked, so it never leaves your browser.
How SQL Formatter behaves in detail
These are the specifics of this implementation — the exact ranges, defaults and fixed settings you are working with.
| Parameter | Value |
|---|---|
| Keyword list | 21 alternatives: select, from, where, group by, order by, having, limit, join, left join, right join, inner join, union, insert into, values, update, set, delete from, and, or, on, as |
| Matching | case-insensitive with word boundaries, so Select, SELECT and select all match |
| Replacement | a newline is inserted before the keyword; its original casing is preserved and nothing is uppercased |
| Indent | none — every clause begins at column zero |
| Cleanup | runs of blank lines collapse to one and the finished text is trimmed |
Compiled from the implementation of this tool and checked against it by itoolnet.
What SQL Formatter does not do
Knowing the edges of a tool saves more time than another list of its features. These are the cases where it will not do what you might expect.
- A word boundary is the only protection, so keywords inside string literals and comments are split as well: a filter written as 'Salt and pepper' gets a line break inside the quoted value, changing the literal itself.
- There is no indentation and no wrapping of continuation lines. Every clause starts at column zero and a long SELECT column list is left on one line, so a nested query comes out completely flat.
- Only the listed 21 keywords trigger a break. Clause and operator words outside that list — distinct, case, when, then, else, end, asc, desc, with, offset, cross join, into — get no line of their own.
- An identifier that happens to spell one of the keywords is broken too, because the rewrite has no notion of where a name ends: an unquoted column called as, set, values or on is pushed onto its own line.
Tested and documented by itoolnet, the team that builds and maintains this site.