Paste a SQL query to format it with a line break before each major clause (SELECT, FROM, WHERE, JOIN, GROUP BY, ORDER BY and more).
Google AdSense Banner
This area will contain advertisements after approval.
Google AdSense Banner
This area will contain advertisements after approval.
This is a keyword-based formatter, not a full SQL parser: it recognizes major clause keywords (SELECT, FROM, WHERE, JOIN variants, GROUP BY, ORDER BY, HAVING, and more) and inserts a line break before each one, then indents AND/OR conditions within a WHERE clause. This produces readable formatting for typical single-statement queries.
Because it works from keywords rather than a true SQL grammar, this tool won't perfectly handle every edge case, deeply nested subqueries, vendor-specific syntax, or unusual keyword usage inside string literals may not format exactly as a dedicated SQL IDE would. For everyday query cleanup and readability, it works well.
Formatting 'SELECT id, name FROM users WHERE age > 18 ORDER BY name' produces four lines, one per major clause: 'SELECT id, name', 'FROM users', 'WHERE age > 18', and 'ORDER BY name', each keyword uppercased and pushed to the start of its own line. A query with multiple conditions, like '...WHERE age > 18 AND status = \'active\'', would additionally indent the AND onto its own line beneath WHERE.
Expecting this to catch SQL syntax errors, it's a whitespace/line-break formatter based on keyword matching, not a real SQL parser, invalid SQL will still get reformatted rather than flagged as an error.
Assuming it understands vendor-specific dialects perfectly, unusual syntax from a specific database (like PostgreSQL's DISTINCT ON or SQL Server's TOP) may not break onto its own line the way standard clause keywords do.
Expecting keywords appearing inside string literals to be left alone in all cases, since this is a keyword-matching formatter rather than a full parser, an unusual literal that happens to contain a clause keyword could in rare cases get an unwanted line break.
Yes, it recognizes keywords from INSERT INTO/VALUES, UPDATE/SET, and DELETE FROM statements too, not just SELECT queries.
No, only whitespace and line breaks are changed, the query's keywords, identifiers and logic are left exactly as written.
Google AdSense Banner
This area will contain advertisements after approval.