SQL formatter
A query you can read, from one you were handed.
Examples temporarily replace the input and settings. You can restore your previous work.
0 characters
Output
Paste or type above to see the result here.
Your files stay on your device
This tool runs entirely in your browser. What you paste is processed on your device and is never sent to a server, so it is safe to use with tokens, keys and unpublished text.
Example
Worked example — SQL formatter
Use the input lines in order and the settings below. Compare your result with the output rows.
| Item | Value |
|---|---|
| Input 1 | select name,age from people where age>=18 order by name; |
| Keywords | UPPERCASE |
| Indent | Two spaces |
| One column per line under SELECT | On |
| Output 1 | SELECT |
| Output 2 | name, |
| Output 3 | age |
| Output 4 | FROM people |
| Output 5 | WHERE age >= 18 |
| Output 6 | ORDER BY name; |
Keywords become uppercase and the two selected columns get separate lines. Formatting does not execute the query.
How it works
- Paste the SQL.
- Choose how keywords are written and how far each level is indented.
- Copy the result, or keep editing: it is laid out again as you type.
Frequently asked questions
- Will it break a query it does not understand?
- It does not try to understand it. The text is split into words, strings and comments and laid out by clause, so a half-written query, a dialect it has never seen or a stored procedure all come back formatted rather than refused.
- Are my strings and comments safe?
- Yes. Anything in quotes, backticks or brackets, and every -- or /* */ comment, is carried through character for character.
- Is the SQL sent anywhere?
- No. It is formatted in your browser as you type, which matters when the query has real table names in it.
Related tools
{} JSON Formatter Paste JSON, get it indented, minified or validated instantly. Your data stays on this page. ‹› XML formatter Indented to be read, or squeezed to one line to be sent. ⇄ Converters CSV to JSON Turn spreadsheet exports into JSON for APIs, scripts and config files, without your data leaving the page. ≠ Text tools Text Diff Paste two versions of a text and see exactly which lines changed.