Utilo

SQL Formatter & Dialect Converter

Free SQL formatter online. Beautify queries and convert syntax between MySQL, PostgreSQL, SQLite and SQL Server. Runs in your browser, no signup.

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

  1. Paste SQL into the input.
  2. Choose the source dialect and, if you want to convert, a target dialect. Leave the target as "keep" to only format.
  3. Pick keyword case and indentation width.
  4. Review the notes panel: anything the converter could not translate safely is listed there.
  5. Copy the result.

Practical examples

  • Messy dump from an ORM: paste a single-line SELECT with nested joins and format it so you can see which ON clause belongs to which table.
  • Moving a schema to Postgres: convert MySQL CREATE TABLE with `id` INT AUTO_INCREMENT into PostgreSQL "id" SERIAL (or GENERATED BY DEFAULT AS IDENTITY).
  • Porting a report query: rewrite LIMIT 20 OFFSET 40 for SQL Server as OFFSET 40 ROWS FETCH NEXT 20 ROWS ONLY, and swap IFNULL for COALESCE.
  • Code review: format both the old and new query with the same settings before diffing them, so whitespace noise disappears.

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.

Tips and limitations

  • Dialect conversion is pattern-based, not a full compiler. Stored procedures, triggers, vendor-specific 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 run it against the target database before shipping.
  • Prefer formatting before converting: a readable query is easier to spot when a rewrite was incomplete.
  • Keep the source dialect correct. Feeding Postgres SQL marked as MySQL can produce wrong quoting.

Frequently asked questions

Does formatting change what my query does?

No. Formatting only changes whitespace and keyword case. Identifiers and literals are untouched.

Can I format multiple statements?

Yes. Separate them with semicolons and each statement is formatted on its own.

Why is my query not converted completely?

Some constructs have no direct equivalent in the target dialect. The notes panel lists what needs attention so you can finish those pieces by hand.

Is my SQL uploaded?

No. Formatting and conversion run entirely in your browser. You can disconnect from the network after the page loads and the tool still works.

Which dialects are supported?

MySQL, PostgreSQL, SQLite and SQL Server for both formatting and conversion. Formatting also understands several aliases of these dialects used by the underlying engine.

Yes. All processing happens directly in your browser using JavaScript, Web Workers and Web APIs. Nothing you type, paste or upload is sent to our servers.