SQL Formatter & Minifier

Pretty-print or compress SQL queries across MySQL, PostgreSQL, T-SQL, SQLite, BigQuery, Oracle, and more. Runs entirely in your browser — your queries never leave your device.

Input

0 chars

Output

Why format SQL?

SQL written in application code tends to be ugly — one long line with no indentation, or broken awkwardly across strings. Pasting it into a database client or code review is painful. A formatter converts the raw query into a readable, multi-line form where each clause (SELECT, FROM, JOIN, WHERE, GROUP BY) starts on its own line, columns line up, and subqueries are properly indented. Pasting back into your ORM / repository, you usually want the minified form — one line, no excess whitespace, ready for the network.

Dialect differences that matter

  • MySQL & MariaDB — backticks (`column`) for identifiers, LIMIT for paging, AUTO_INCREMENT keyword.
  • PostgreSQL — double-quotes ("column") for case-sensitive identifiers, LIMIT ... OFFSET, RETURNING clause, ILIKE.
  • T-SQL (SQL Server) — square brackets ([column]) for identifiers, TOP N instead of LIMIT, OFFSET ... FETCH NEXT for paging.
  • Oracle PL/SQL — no auto-increment (sequences instead), ROWNUM or FETCH FIRST, dual table idioms.
  • BigQuery — standard SQL-ish with backticks for project.dataset.table, STRUCT and ARRAY types, UNNEST.

Picking the right dialect here ensures the formatter recognises keywords like TOP, ILIKE, or UNNEST correctly and doesn't mangle dialect-specific identifier quoting.

When to minify

Minify when you're committing a query into a string literal (ORM, stored procedure source, migration file), logging traffic, or sending it over a network where wire-size matters. Minification removes line breaks and collapses repeated whitespace while preserving everything inside string literals and comments. The parse tree and execution plan are byte-identical to the formatted version.

Privacy & offline

This formatter runs in your browser using the open-source sql-formatter library. Your queries are never uploaded, logged, or sent to a server. Once the page loads, the tool works offline.

Related tools