SQL Formatter
Format SQL queries into readable, indented lines, or minify them to one, in your browser
Keywords
SQL
The SQL isn't checked, it's only laid out
Formatted
How to format SQL
- Paste or type your SQL query.
- Choose Format for readable lines, or Minify for one line.
- Choose keywords in uppercase, lowercase or as typed, and 2 or 4 spaces.
- Copy the formatted SQL.
Questions
Which SQL dialects work?
Standard SQL and the common dialects: PostgreSQL, MySQL, SQLite and SQL Server. Strings, quoted names, comments, parameters and casts are kept as they are.
Does it check my SQL?
No, it formats without checking that the query is valid, so even a broken query can be tidied up to find the mistake.
How is the query laid out?
Each clause on its own line, its contents indented under it, one column, condition (AND, OR) or CASE branch a line, and subqueries indented.
Is my query sent anywhere?
No, it's formatted by your browser, so table names and data stay private.