SQL Formatter

Format a SQL query: indentation, line breaks, keyword case. Multiple dialects supported.

sql
mysql
postgresql
sqlite
mariadb
transactsql
bigquery
UPPER
lower
SQL
Result
SELECT u.id, u.name, count(o.id) AS orders FROM users u LEFT JOIN orders o ON o.user_id = u.id WHERE u.active = 1 GROUP BY u.id, u.name HAVING count(o.id) > 0 ORDER BY orders DESC LIMIT 10;

The SQL formatter turns a long, indent-free query into readable, neatly structured code: each keyword (SELECT, FROM, WHERE, JOIN, GROUP BY) starts on its own line, nested conditions get indented, and the list of fields and conditions lines up in a column.

This is especially useful for queries copied from logs, ORM debug output, or someone else's code, where everything is squashed onto one line. A formatted query is much easier to read and check for mistakes.

The tool supports several SQL dialects (MySQL, PostgreSQL, SQLite, MariaDB, T-SQL, BigQuery and standard SQL) and lets you choose upper or lower case for keywords. Everything runs in your browser — the query is never sent to a server.

Frequently asked questions

Standard SQL, MySQL, PostgreSQL, SQLite, MariaDB, T-SQL (Transact-SQL) and BigQuery. The dialect choice affects recognition of dialect-specific syntax like TOP in T-SQL.
No, formatting happens entirely in the browser via JavaScript. The query text is never transmitted anywhere.
It only checks the syntactic structure needed for formatting. It's not a full SQL linter and doesn't replace running the query against a real database.