Developer guide
How to format SQL by database dialect
SQL formatting improves the visual structure of clauses, joins, expressions, and subqueries, but the selected dialect determines how vendor-specific syntax is parsed.
Open the SQL FormatterWhat SQL formatting changes
A formatter adjusts whitespace, indentation, line breaks, and keyword case. It can make joins, predicates, grouped expressions, and nested queries easier to review without connecting to a database or running the statement.
A well-formatted query can still be slow, unsafe, or logically wrong. Formatting is a reading aid rather than execution analysis.
How to format SQL
- Choose Standard SQL, PostgreSQL, MySQL, SQLite, T-SQL, or BigQuery.
- Select two spaces, four spaces, or tabs.
- Choose uppercase, lowercase, or preserved keyword case.
- Paste the query and select Format SQL.
- Review quoted identifiers, placeholders, and vendor-specific statements.
Choosing the dialect first is important because identifier quotes, parameter forms, operators, and statement syntax vary.
A SQL formatting example
Input
select u.name,count(o.id) from users u left join orders o on o.user_id=u.id group by u.name
Readable output
SELECT
u.name,
COUNT(o.id)
FROM users u
LEFT JOIN orders o ON o.user_id = u.id
GROUP BY u.name
Why dialect selection matters
| Area | Possible differences |
|---|---|
| Identifiers | Double quotes, backticks, or brackets |
| Parameters | ?, $1, @name, named forms |
| Pagination | LIMIT, TOP, or fetch syntax |
| Procedural code | Vendor-specific blocks and delimiters |
What formatting does not check
- Whether tables and columns exist.
- Whether permissions allow the statement.
- Whether user input is parameterized safely.
- Whether indexes support the query plan.
- Whether every stored procedure or extension is supported by the formatter.
Use the database's parser, explain plan, tests, and security review for those questions.
Use the browser tool
Format common SQL locally with a selected dialect, indentation style, and keyword case.