SQL Formatter
Beautify SQL queries with consistent indentation and casing. Supports MySQL, PostgreSQL, SQL Server, SQLite, BigQuery, and more. All client-side.
Runs in your browser — nothing uploaded
Paste any SQL query and get it back nicely indented with consistent keyword casing. Supports every major dialect — MySQL, Postgres, SQL Server, BigQuery, Snowflake, and more. Useful for cleaning up ORM-generated SQL, sharing readable queries in pull requests, and debugging chains of joins.
Private by design — your data never leaves your device
How to use it
No account, no upload — it all happens on your device.
1
Paste your SQL into the input box. Click 'Load sample' to see an example.
2
Pick the dialect that matches your database — defaults to Standard SQL.
3
Choose keyword casing (UPPER, lower, or Keep) and indent width.
4
Copy the formatted result with the Copy button. Nothing is uploaded.
Why format SQL?
The same query, two readabilities.
- Pull requests review faster. A 200-character one-liner is a wall; the same query indented across 15 lines with one clause per line tells a story.
- Bugs are easier to spot. Missing comma in a SELECT list, an accidental cartesian join, a misplaced WHERE/HAVING — all jump out in formatted SQL and hide in compressed SQL.
- Dialect-aware spacing handles window-function OVER clauses, CTEs (WITH … AS), and array / struct syntax differently across BigQuery, Postgres, and Snowflake.
Conventions this tool follows
- One clause per line. SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY each start a new line.
- One column per line in SELECT. Easier diffs when you add or remove columns later.
- Lines indent inside parens. Subqueries, CTEs, and CASE expressions get a clear nested block.
- Keyword case is your choice. The traditional team-wide rule is uppercase keywords with lowercase identifiers; pick whatever matches your team style.
What this tool isn't
- A linter. It won't tell you that
SELECT *is bad practice or that you should use explicit JOINs. - A query optimizer. It only changes whitespace and keyword case — your query plan is identical before and after.
- A schema validator. It can't check whether
users.created_atexists in your database.
Frequently asked
Which SQL dialects are supported?
MySQL, MariaDB, PostgreSQL, SQLite, SQL Server (T-SQL), Oracle (PL/SQL), BigQuery, Snowflake, Redshift, Spark SQL, Trino, DB2, Hive, Couchbase N1QL, plus generic SQL. Pick the one closest to your engine — it changes how keywords, functions, and operators are recognized.
Does the formatter validate my SQL?
It tries to parse the query before formatting, so syntactically broken SQL will surface an error message. But it doesn't validate against a real database schema — column names, table names, and join correctness are not checked. Use a real database engine or a linter like SQLFluff for deep validation.
Is my SQL uploaded?
No. The sql-formatter library runs entirely in your browser. The query you paste stays on your device — even if it contains real data, internal schema names, or production references.