How to use the SQL Formatter
- Paste a query or open a .sql file.
- Choose your database dialect, keyword case and indentation.
- Copy or download the formatted SQL.
Why format SQL?
Queries copied from ORMs, logs and monitoring tools arrive on one line. Consistent formatting — one clause per line, indented joins and conditions, uppercase keywords — makes them far easier to review, debug and diff.
Dialect matters
Each database has its own syntax: PostgreSQL's :: casts and $1 parameters, MySQL's backtick identifiers, T-SQL's square brackets, BigQuery's backtick table paths. Choosing the right dialect lets the formatter recognise them instead of breaking them apart.
What the formatter doesn't do
It changes only whitespace and keyword case. It doesn't validate that tables exist, optimise the query, or run it. Formatting happens in your browser with the open-source sql-formatter library, so queries containing real data stay private.
Frequently asked questions
My query contains template placeholders and fails to format.
Placeholders like {{ variable }} aren't valid SQL. Replace them with a literal or a parameter (?, $1, :name) before formatting.
Does it support stored procedures?
Common procedural blocks for PL/SQL and T-SQL are supported, but very complex procedural code may not format perfectly.