D
Devault

SQL Formatter

Format and minify SQL with multi-dialect support — ANSI, SAP HANA, Oracle, MySQL, PostgreSQL

Input
Output
⌘↵ to format

About SQL Formatter

Long SQL statements written on one line, or generated by an ORM, are hard to review. Consistent formatting puts each clause on its own line, indents subqueries and joins, and normalizes keyword case so the structure of the query is visible.

This formatter supports ANSI SQL, Oracle PL/SQL, MySQL, and PostgreSQL, and — separately — SAP HANA SQLScript, because keywords and quoting rules differ between databases. Formatting only changes layout and keyword style; it does not run the query or connect to any database.

SAP HANA is the one dialect most online SQL formatters skip, because SQLScript is procedural: a stored procedure wraps ordinary SQL in a DO BEGIN ... END block that can declare variables, open cursors, and branch with IF/WHILE/FOR. This formatter indents that block structure the same way it indents parentheses, so a procedure body like DO BEGIN DECLARE v_count INTEGER; SELECT COUNT(*) INTO v_count FROM users; END comes out with the declaration and query nested one level inside BEGIN, instead of collapsing onto a single unreadable line.

Common use cases

  • Making an ORM-generated query readable during debugging.
  • Cleaning up a query before adding it to code review or documentation.
  • Formatting a HANA SQLScript stored procedure or calculation view definition.
  • Applying a consistent style to SQL stored in migration files.

Frequently asked questions

Does formatting change what the query does?
It should not. Only whitespace and keyword case change. Always run your tests, especially for dialect-specific syntax.
Which dialect should I choose?
Choose the database you run the query on. Using the wrong dialect can mis-handle quoting and vendor-specific keywords.
Does it handle HANA's procedural SQLScript, not just plain SELECT statements?
Yes. DO BEGIN...END blocks, DECLARE, cursors, and IF/WHILE/FOR control flow are recognized and indented as nested blocks, not just the SQL statements inside them.
Is my query sent to a database or server?
No. Formatting happens in your browser and nothing is executed.