About the SQL Formatter
A SQL query written as one long line — or generated by an ORM — is hard to review, especially with several joins, subqueries, or a long WHERE clause. Consistent formatting makes queries far easier to read, debug, and review in a pull request.
This tool reformats SQL with proper indentation and keyword casing, with support for multiple SQL dialects so the output matches the conventions of the database you're actually using.
How it works
- Paste your SQL query into the input box.
- Choose the dialect that matches your database (PostgreSQL, MySQL, SQLite, BigQuery, T-SQL, and more).
- Click Format to get a cleanly indented version with uppercase keywords.
Common use cases
- Reviewing ORM-generated queries: Formatting a long, single-line query logged by an ORM (like Prisma or SQLAlchemy) to actually understand what it's doing before optimizing it.
- Preparing a query for a pull request: Cleanly formatting a migration or reporting query so reviewers can follow the joins and conditions at a glance.
- Cross-dialect comparison: Formatting the same query under different dialect settings to see how syntax highlighting or keyword conventions differ.
Frequently asked questions
Why does dialect selection matter?
Different databases have dialect-specific syntax — for example, BigQuery's backtick-quoted identifiers or T-SQL's square brackets — and choosing the right dialect helps the formatter parse and indent dialect-specific constructs correctly.
Does this tool validate my SQL for correctness?
It formats syntax it recognizes but isn't a full SQL engine — it won't catch logical errors like referencing a non-existent column, only structural formatting.
Will formatting change the meaning of my query?
No — formatting only affects whitespace, indentation, and keyword casing; the query's logic, table names, and values are left completely unchanged.
Can I format stored procedures or multiple statements at once?
Yes, multiple semicolon-separated statements can be pasted in and will each be formatted, though very complex procedural extensions (like custom stored-procedure syntax) may format inconsistently depending on the dialect.
This tool runs entirely in your browser — nothing you enter is sent to a server. Read more in the Privacy Policy, or browse the full list of tools.