How to use the sql formatter
- Paste your SQL.
- Choose indentation and keyword case.
- Copy the formatted query.
How queries are laid out
SELECT, FROM, WHERE, GROUP BY, ORDER BY and similar clauses each start a new line. Selected columns get one line each, AND/OR conditions are indented under WHERE, joins stay on one line with their ON condition, and subqueries are indented inside their brackets. It works with MySQL, PostgreSQL, SQLite and SQL Server syntax.
Examples
SELECT id, name FROM users WHERE active = 1
COUNT(o.id)