SQL formatter
Paste SQL and get readable formatting — keywords cased, clauses on new lines, joins and conditions indented. Or flip to compact mode to minify.
Options
Input SQL
Formatted output
Paste SQL above to see formatted output.
Everything runs in your browser — your SQL never leaves this page. This is a pragmatic formatter, not a full SQL parser: string literals and comments are preserved, but dialect-specific syntax may not format perfectly.
About this tool
Readable SQL saves time in code review, debugging slow queries, and sharing snippets. This formatter tokenizes your input, keeps strings and comments intact, uppercases or lowercases keywords, and breaks major clauses onto their own lines with sensible indentation for joins,AND/OR chains, and subqueries.
It does not aim for full dialect coverage — PostgreSQL, MySQL, and SQLite share enough common syntax that the basics work well, but exotic constructs (dollar-quoted strings, vendor-specific functions) may format oddly. Use compact mode when you need a single line, not a production query optimizer.