What this SQL formatter does
This tool does two jobs. First, it formats SQL: one clause per line, consistent indentation, upper- or lower-case keywords and readable JOIN and CASE blocks, using the battle-tested sql-formatter engine with dialect-aware parsing. Second, it performs basic dialect conversion between MySQL, PostgreSQL, SQLite and SQL Server, handling the differences that bite most often when moving a query or a schema between databases. Everything runs locally, so production queries containing real table names never leave your browser.
How to use it
- Paste SQL into the input.
- Choose the source dialect and, if you want to convert, a target dialect. Leave the target as "keep" to only format.
- Pick keyword case and indentation width.
- Review the notes panel: anything the converter could not translate safely is listed there.
- Copy the result.
What the converter handles
- Identifier quoting:
`name`(MySQL) ↔"name"(PostgreSQL/SQLite) ↔[name](SQL Server). - Row limits:
LIMIT n OFFSET m↔TOP n↔OFFSET m ROWS FETCH NEXT n ROWS ONLY. - Auto-increment:
AUTO_INCREMENT↔SERIAL/GENERATED ... AS IDENTITY↔AUTOINCREMENT↔IDENTITY(1,1). - Common types:
DATETIME/TIMESTAMP,TINYINT(1)/BOOLEAN/BIT,NVARCHAR,TEXT,BLOB/BYTEA/VARBINARY(MAX). - Functions:
NOW()/GETDATE()/CURRENT_TIMESTAMP,IFNULL/ISNULL/COALESCE,RAND()/RANDOM(),CONCAT↔||. - String literals and comments are protected, so a keyword inside
'quotes'is never rewritten.
Limitations
Dialect conversion is pattern-based, not a full compiler. Stored procedures, triggers, vendor-specific functions (window frame quirks, JSON operators, MERGE, ON DUPLICATE KEY vs ON CONFLICT) and collation details need a manual review. Treat the output as a strong first draft and test it against the target database.