SQL Formatter
Turn a one-line or messy SQL statement into a readable, consistently indented query with each clause on its own line.
- Runs in your browser
- Free to use
About this tool
Long SQL statements written on one line, or copied from logs and ORMs, are hard to review. The SQL Formatter breaks a query into one clause per line (SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY, LIMIT…), indents the column list and conditions, keeps JOINs together with their ON clause, indents CASE expressions and nested parentheses, and optionally uppercases keywords, all in your browser.
Related: JSON Beautify and the CSS / JavaScript beautifiers.
How to use it — quick steps
- 01
Enter the sql
Type or paste the sql in the field above. Nothing is uploaded: the text stays in your browser.
- 02
Adjust the options
Pick the settings that fit your case; the defaults work for most people. Changes apply instantly.
- 03
Press "Format SQL"
Press "Format SQL" or Ctrl + Enter. The result appears instantly below the form. Results can be copied.
Key features of this tool
Nothing leaves your browser
The processing is plain JavaScript that runs on your device: the text you paste is never uploaded to our servers or to anyone else.
Instant results
Results appear the moment you press the button, even for long inputs, and every block has copy and download actions.
Works everywhere
No installation, no account and no limits: the tool works on desktop and mobile, in any modern browser, as often as you like.
Frequently asked questions
Which SQL dialects are supported?
The formatter works on structure (clauses, joins, parentheses, commas, AND/OR, CASE) rather than on a dialect grammar, so MySQL, PostgreSQL, SQL Server, SQLite and most others format fine; strings and comments are left untouched.
Does it change the meaning of the query?
No. Only whitespace and line breaks are changed, and keyword case when the option is on; identifiers, literals and operators are preserved.
Can I format several statements?
Yes, statements separated by semicolons are each formatted in turn.
Are my files or data uploaded?
No. The tool is plain JavaScript that runs in your browser; the files or data you provide here are never uploaded to our servers.