Paste a SQL query to format, beautify, or minify it. Keywords are uppercased, clauses are placed on new lines, and subqueries are indented. Runs entirely in your browser — nothing is uploaded.
A SQL formatter (also called a SQL beautifier) takes a compact or inconsistently formatted SQL query and restructures it for maximum readability. It uppercases reserved keywords, places each major clause on its own line, and indents subqueries and nested expressions so the logical structure of the query is immediately visible.
.sql fileThe formatter recognises and uppercases all common ANSI SQL keywords including: SELECT, FROM, WHERE, JOIN (all variants), ON, AND, OR, GROUP BY, ORDER BY, HAVING, INSERT INTO, UPDATE, DELETE, CREATE, ALTER, DROP, UNION, CASE, WHEN, THEN, ELSE, END, IN, EXISTS, BETWEEN, LIKE, IS NULL, IS NOT NULL, AS, SET, VALUES, LIMIT, OFFSET, DISTINCT, ALL, ANY, and more.
Well-formatted SQL is significantly easier to read, debug, and peer-review than a single-line query. The most impactful habit is placing each major clause — SELECT, FROM, WHERE, JOIN, GROUP BY, ORDER BY — on its own line. This makes it trivial to comment out a single clause during testing and instantly reveals the logical structure of the query. Uppercasing all keywords distinguishes them visually from table and column names, which is especially useful when column names happen to overlap with SQL reserved words.
Consistent formatting makes SQL diffs meaningful — when two developers format queries the same way, a version-control diff reflects only logical changes rather than style noise. Two popular column-list styles exist: trailing commas (comma at end of each line) are more common and easier to type, while leading commas (comma at start of the next line) make it easier to add or remove the last column without adjusting punctuation. Either is fine as long as a team is consistent. Always qualify column names with their table alias in multi-table queries — u.email instead of just email — to make the query self-documenting and immune to ambiguous-column errors when schemas change.
Minified SQL (collapsed to a single line) is useful when embedding a query in application code as a string literal, in log files where multi-line output is impractical, or in ORM-generated query strings. It has no performance benefit — database query planners ignore whitespace — so always keep a formatted version as the source of truth in your codebase and minify only for specific output needs.