How do I format a SQL query?
Paste your query and it is reformatted instantly: each major clause moves to its own line, keywords are uppercased, and spacing around commas, operators and parentheses is normalized. The built-in example goes from one long line to seven readable lines: SELECT with the column list, then FROM, LEFT JOIN ... ON, WHERE, GROUP BY, ORDER BY and LIMIT each starting a fresh line. Function calls stay tight (COUNT(o.id), not COUNT ( o.id )), table.column names keep their dot, and strings like '2026-01-01' are never touched. You can turn keyword uppercasing off if your team prefers lowercase keywords.
What does the formatter change, and what does it leave alone?
It changes layout only, never meaning. Clause starters (SELECT, FROM, WHERE, GROUP BY, ORDER BY, HAVING, LIMIT, OFFSET, UNION, INSERT INTO, VALUES, UPDATE, SET, DELETE FROM, and every JOIN type) begin new lines at the top level; inside parentheses the query stays inline so subqueries and IN lists remain compact. String literals in single quotes, double quotes or backticks are preserved character for character, including doubled-quote escapes, and both -- line comments and /* block comments */ survive formatting, each on its own line. Keywords inside strings are not uppercased and do not trigger line breaks, so a value like 'select from where' stays exactly as written.
When should I minify SQL instead?
Minify mode squeezes a query onto a single line by removing unnecessary whitespace while keeping the spaces SQL actually needs between words. The formatted example (7 lines) minifies back to a single line. Minified SQL is handy for log lines, config files, environment variables, and embedding a query in code or a URL where newlines cause trouble. It is the same query with the same meaning; databases do not care about whitespace. Keep the formatted version in your source files for humans, and minify only the copy that goes into a machine-facing place.
Which SQL dialects does it work with?
The formatter works on the common core shared by MySQL, PostgreSQL, SQLite, SQL Server and standard SQL: SELECT, INSERT, UPDATE, DELETE, joins, grouping, ordering, unions and basic DDL such as CREATE TABLE, ALTER TABLE and DROP TABLE. Dialect-specific syntax passes through unchanged because the formatter only rearranges whitespace and keyword case; it never rewrites identifiers, operators or values. Statements are counted by semicolons, so a script with an INSERT, an UPDATE and a DELETE reports 3 statements, and each one is formatted independently. Vendor functions outside the built-in list keep their original case, which is safe if slightly less uniform.
Why format SQL at all?
Readable queries are easier to review, debug and hand over. A clause-per-line layout makes missing commas, wrong join conditions and accidental full-table updates visible at a glance: in a one-line UPDATE, the WHERE clause hides at the end; formatted, its absence is obvious. Consistent keyword casing lets you scan structure quickly, and normalizing a query before pasting it into a pull request, a ticket or documentation saves every reader time. Formatting before comparing two query versions also makes diffs show real changes instead of whitespace noise. It takes one paste, so there is little excuse for shipping a 400-character one-liner.
Is it free and private?
Yes. The SQL formatter is free, with no signup, no account and no limits. Formatting runs entirely in your browser, so your queries, table names and data values are never sent to a server, stored or logged, which matters when production SQL contains sensitive schema details. For developers, analysts and DBAs who read and write SQL every day, this page does the job in seconds.