SQL Formatter
Drop a one-line query into the SQL box (the sample starts as select id,name from users where active=1 order by name), then click Format. The tool collapses extra spaces, uppercases clauses like SELECT and WHERE, starts each major keyword on its own line, and indents items after commas.
Click Format.
About this tool
This is a lightweight readability helper, not a full SQL parser. It pattern-matches common keywords, normalizes whitespace, and rewrites commas so column lists stack neatly. Invalid or empty input shows Enter SQL until you provide text.
How to use
- Open the formatter: Load the page and locate the SQL textarea and Format button.
- Paste your query: Replace the sample with the SQL you want to reformat.
- Click Format: Press Format to collapse spaces, uppercase keywords, and break lines.
- Copy the output: Select the formatted block in the result area and paste it where needed.
Common use cases
- Make a logged one-liner from production readable before pasting into a ticket.
- Tidy SELECT lists copied from ORM debug output for code review slides.
- Teach students how clause order looks when keywords are visually separated.
Tips
- Subqueries and nested parentheses stay inline; review odd breaks before sharing.
- Keywords inside string literals may still be uppercased if they match the keyword list.
FAQ
Does this validate SQL syntax?
No. It only rewrites spacing and keyword casing for readability.
Which keywords get their own line?
Common clauses such as SELECT, FROM, WHERE, JOIN, GROUP BY, and ORDER BY.
What happens to commas?
Each comma becomes a line break followed by two spaces for list items.
Is my query sent to a server?
Formatting runs locally in the browser when you click Format.