How SQL formatting works
A SQL formatter doesn't change what a query does — it changes how it looks. It tokenizes the statement, then puts each major clause on its own line, indents nested expressions, and standardizes the case of keywords. The result reads top-to-bottom in the order the database thinks about the query.
Major keywords like SELECT, FROM, JOIN, WHERE, GROUP BY, ORDER BY and LIMIT start new lines; AND/OR inside a WHERE are indented under it; and the select list is laid out so each column is easy to scan.
Worked example
A cramped one-line query becomes:
What it does and doesn't do
This formatter is a readability tool: it reformats whitespace, line breaks and keyword case while leaving your logic, identifiers and string literals untouched. It works across common dialects (MySQL, PostgreSQL, SQL Server, SQLite) because it keys off standard keywords. It does not validate or execute your SQL, optimize it, or rename anything — it won't catch a syntax error, only make one easier to spot. Strings and quoted identifiers are preserved exactly so your data is never altered.