Format and beautify SQL queries online with proper indentation and uppercase keywords. Also minify SQL — free tool supporting SELECT, JOIN, WHERE, GROUP BY, and more.
What is SQL Formatter?
SQL Formatter is a free online tool that beautifies and formats
SQL queries with proper indentation, line breaks, and keyword
capitalization. It transforms messy, single-line, or poorly
formatted SQL into clean, readable code that is easy to review
and debug. The tool also includes a Minify mode that strips all
unnecessary whitespace and comments to produce compact SQL for
use in scripts or configurations. All formatting runs entirely
in your browser using vanilla JavaScript with no external
libraries or server calls.
When to use it?
Use the SQL Formatter when you receive a long, single-line SQL
query from a log file, ORM debug output, or a colleague's code
and need to understand its structure. It is also helpful during
code reviews when comparing SQL changes, or when documenting
queries in technical specifications and wiki pages where
readability is essential. The minify mode is useful for
embedding SQL in application code where you want to reduce
string length.
Common use cases
Database administrators and back-end developers commonly use SQL
Formatter to clean up auto-generated queries from ORMs like
Sequelize, Prisma, or Hibernate, format complex JOIN statements
with multiple WHERE conditions for debugging, prepare readable
SQL snippets for documentation and pull request descriptions,
standardize keyword casing across team codebases, and minify
stored procedures or migration scripts for deployment. It
supports common SQL keywords including SELECT, FROM, WHERE,
JOIN, GROUP BY, ORDER BY, HAVING, INSERT, UPDATE, DELETE,
CREATE, ALTER, and DROP.
SQL formatting conventions across databases
SQL formatting styles vary across database platforms and teams. Most style guides agree on uppercase keywords (SELECT, FROM, WHERE, JOIN), consistent indentation for sub-clauses, and placing each column on its own line for complex queries. PostgreSQL developers tend to use lowercase keywords with 4-space indentation, while Oracle shops prefer uppercase with 2-space indentation. The critical principle is consistency within your codebase — pick a style and enforce it. This formatter supports multiple SQL dialects including standard SQL, PostgreSQL, MySQL, T-SQL, and PL/SQL.
Why formatted SQL matters for code review
Unformatted SQL makes code reviews significantly harder. A single-line query like SELECT a.id, b.name FROM users a JOIN orders b ON a.id = b.user_id WHERE a.active = 1 AND b.total > 100 ORDER BY b.created_at DESC LIMIT 50 obscures logic and makes it easy to miss issues. Properly formatted, each clause is visible at a glance: missing indexes become obvious, join conditions are easy to verify, and WHERE clause logic is clear. Teams that enforce SQL formatting see fewer bugs in data queries and faster onboarding for new developers.