SQL Formatter
SQL formatter. Paste any SQL query and get it formatted with consistent indentation, one clause per line, and keywords in upper or lower case. Choose a dialect such as MySQL, PostgreSQL, SQL Server, or SQLite, then copy the result. It also minifies queries to one line. Formatting runs in your browser, so queries stay private.
How to use
- Paste a SQL query into the box.
- Choose a dialect: Standard SQL, MySQL, PostgreSQL, SQL Server, SQLite, or BigQuery. Then choose uppercase or lowercase keywords.
- Click Format. SELECT, FROM, WHERE, and JOIN each start on their own line.
- Click Minify to remove comments and extra spaces and put the query on one line, then copy the result.
How it works
Formatting changes whitespace and keyword case only. Table names, quoted text, and the query logic stay the same. Each clause such as SELECT, FROM, WHERE, and JOIN starts a new line, with two-space indents inside parentheses. Minify removes comments and collapses whitespace outside quotes onto one line. Nothing is uploaded.
Example. select id, name from users where status = 'select' prints SELECT, then id and name on their own lines, then FROM users and WHERE status = 'select'. The quoted word select stays lowercase.
Example. Minify removes the comment in select id /* keep */ from t -- note and leaves SELECT id FROM t.
Dialects change keywords, not your data
Standard SQL, MySQL, PostgreSQL, SQL Server (T-SQL), SQLite, and BigQuery share the common clauses. A dialect adds its own keywords, such as ILIKE in PostgreSQL, TOP in SQL Server, and QUALIFY in BigQuery. Words inside quotes, brackets, backticks, and dollar quotes are copied as you typed them.
Frequently asked questions
How do I format a SQL query?
Paste the query, pick your SQL dialect, and click Format. Each clause such as SELECT, FROM, WHERE, and JOIN moves to its own line with consistent indents.
Which SQL dialects are supported?
Standard SQL, MySQL, PostgreSQL, SQL Server (T-SQL), SQLite, and BigQuery.
Does it change what my query does?
No. Only whitespace and keyword case change; table names, values, and logic stay the same.
Is my SQL sent to a server?
No. Formatting happens locally in your browser.
Can it minify SQL?
Yes. Minify removes extra whitespace and comments to put the query on one line.
Related tools
- DevJSON Formatterin-browser JSON pretty-printer, minifier, and syntax validator.
- DevRegex TesterTest JavaScript regular expressions with live match highlighting.
- DevBase64 Decoder & EncoderDecode or encode Base64 text in the browser, with UTF-8 and URL-safe support.
- DevSubnet CalculatorCIDR to netmask, hosts, network, and broadcast for IPv4.
- DevXML FormatterPaste XML to pretty-print, validate, and minify it in the browser.
- DevBarcode GeneratorEncode a SKU or number as Code 128, Code 39, EAN-13, or UPC-A and download PNG or SVG.