SQL Formatter Online — MySQL, PostgreSQL, T-SQL, BigQuery, Snowflake
Format SQL queries for 20+ dialects: MySQL, PostgreSQL, T-SQL, Oracle PL/SQL, SQLite, MariaDB, BigQuery, Snowflake, Redshift, Trino, Hive, Spark, ClickHouse, DuckDB. Custom tab width, UPPERCASE keywords, minify. 100% client-side.
Why use this tool
MySQL ≠ PostgreSQL ≠ T-SQL syntax. The tool uses the industry-standard sql-formatter — parses each dialect correctly, won't break complex queries.
Queries may contain confidential table names / schema. 100% client-side — queries are NOT uploaded. Works offline after page load.
Format for readability or minify to one line for pasting into string literals in code.
How to use
- 1Pick dialect (MySQL / PostgreSQL / T-SQL / ...).
- 2Paste the SQL query into the textarea.
- 3Click Format or Minify. Adjust tab width 1-8 spaces.
- 4Toggle UPPERCASE so keywords (SELECT, FROM, WHERE) are auto-uppercased.
SQL Formatter — Why you need it
SQL from ORMs (Prisma, TypeORM, Sequelize) or raw queries in code is often generated as one long line for the driver. When debugging slow queries / EXPLAIN plans, you need readability: how many columns are SELECTed, what JOINs, what WHERE filters, ORDER BY / LIMIT sanity. A formatter turns a 200-char one-liner into clearly indented multi-line SQL.
The tool uses sql-formatter — the industry-standard npm package, 4.6K+ GitHub stars, supports 20+ dialects. It parses to an AST then re-formats, not simple regex — so it handles nested subqueries, CTE (WITH), window functions, partition by, all JOIN types, lateral joins, set operations (UNION/INTERSECT/EXCEPT) correctly.
Privacy edge over other online formatters (sqlformat.org, sqlfluff online): your query never leaves the browser. Critical if the query reveals sensitive schema (tables users, payments, audit_log) or proprietary business logic.
- ✓20+ dialects (MySQL/PG/T-SQL/Oracle/BQ/Snowflake/...)
- ✓Pretty format with custom indent
- ✓Minify to one line
- ✓UPPERCASE keywords option
- ✓Comments preserved
- ✓Window function support
- ✓CTE (WITH) formatting
- ✓100% client-side
FAQ
Does formatting change my query?
No. Only whitespace + keyword capitalization. Logic is preserved 100%.
Can it format stored procedures / functions?
Partially. Simple CREATE PROCEDURE / FUNCTION blocks format fine. Complex nested BEGIN/END may not look perfect.
'Parser error' on big queries?
sql-formatter parses syntax, not semantics. Syntax errors will fail. Check for missing commas / unclosed parens / typo keywords.
ClickHouse / DuckDB support?
Yes. ClickHouse, DuckDB, Hive, Spark, Trino all supported.