Text & Code
SQL Formatter
Format SQL in your browser with a dialect you choose, adjustable indentation, and copy or download.
Processed locally. Nothing from the editor is stored.
How to use SQL Formatter
Formatting uppercases keywords and indents clauses for the selected dialect. It is a formatter, not a database. A statement the formatter cannot read produces the formatter error and no rewritten SQL.
- Paste a statement and choose a dialect. PostgreSQL, MySQL, MariaDB, SQLite, Transact-SQL, BigQuery, Snowflake, and Standard SQL are available.
- Choose 2 or 4 spaces.
- Format, then copy or download the result. Control+Enter or Command+Enter formats.
Examples
Read a compact query
select a,b from tools where id=1 becomes a SELECT with a, b, FROM, and WHERE on their own indented lines.
Match a dialect
Choose Transact-SQL for T-SQL bracket and keyword rules, or BigQuery when the statement uses that dialect's functions.
Questions
Will this fix invalid SQL?
It only changes whitespace and keyword case. If the formatter throws, the message is shown and the input is left unchanged.
Which keywords are uppercased?
Keywords recognized by the selected dialect. Identifiers in quotes stay as you wrote them.