SQL Formatter
Lay out SQL clauses on their own lines with optional keyword upper-casing.
- Runs locally in your browser
- No upload required
Try it
Supported formats
Privacy
Runs entirely in your browser. Your input is never uploaded, stored, or sent to a third party.
Laid out 1 line(s) of SQL by clause.
How it works
- Tokenised the statement, treating quoted strings and identifiers as opaque.
- Started a new line at each major clause keyword (SELECT, FROM, WHERE, GROUP, ORDER, JOIN, ...).
- Upper-cased recognised SQL keywords.
- String literals, quoted identifiers and comments are copied exactly.
- Output is 4 line(s); formatting it again changes nothing.
Methodology
- Tokenise the statement, keeping strings, quoted identifiers and comments opaque.
- Start a new output line at each recognised clause keyword.
- Optionally upper-case known keywords and normalise inter-token spacing.
Usage
- Paste or type a SQL statement.
- Choose whether to upper-case keywords.
- Run the formatter and copy the laid-out query.
Examples
These are examples, not current values: they use fixed inputs, while the interactive tool computes live results in your browser.
Select with a where clause
{
"text": "select a,b from t where x=1 order by a",
"uppercaseKeywords": true
}String literal preserved
{
"text": "select name from users where name='a b'",
"uppercaseKeywords": true
}Insert statement
{
"text": "insert into t (a,b) values (1,'x')",
"uppercaseKeywords": false
}Limitations
Readable queries
A clause-per-line layout makes a query reviewable and its diff meaningful. The formatter keeps values and identifiers untouched so the query means exactly the same thing.
Frequently asked questions
- Does it change my string values?
- No. Single/double-quoted strings and quoted identifiers are copied exactly.
- Which dialects are supported?
- The layout is generic SQL; common SELECT/INSERT/UPDATE/DELETE/JOIN clauses are recognised regardless of vendor-specific extras.
- Is my query uploaded?
- No. The statement is processed entirely in your browser.
Sources
Send feedback
Tell us if this tool helped, report a problem, or suggest a tool. Only the message you type is sent — never the input you used in the tool.
Was this tool useful?
Prefer to write to us directly? See the contact page.