OmniDev_

~/tools/sql-formatter

SQL Formatter

Format, beautify, and minify SQL queries with dialect-aware formatting. Supports MySQL, PostgreSQL, T-SQL, SQLite, BigQuery, and more. Runs entirely in your browser.

// How to use
1. Paste SQL or upload a .sql file
2. Choose dialect & keyword case
3. Pick indent (2/4 spaces or tab)
4. Copy output or download .sql
5. Use Minify to compress SQL
* all processing happens in browser
100% client-side — no data leaves your browser
sql — formatter

// Mode

// Dialect

// Keyword Case

// Indent

// Input SQL
0 chars · 0 lines
// Output

// Formatted output appears here

What is a SQL Formatter?

A SQL formatter (also called a SQL beautifier) automatically restructures raw SQL queries into a consistent, readable format. It enforces indentation, keyword casing, and line breaks so queries are easy to read, review, and maintain — regardless of how they were originally written.

SQL formatting is critical in professional environments where multiple developers write queries — consistent style reduces cognitive load during code review, makes diffs easier to read, and helps catch logical errors that are obscured by poor indentation.

Supported Dialects

Standard SQL

ANSI SQL — the base standard supported by all major databases. Best for generic queries that don't rely on vendor-specific syntax.

MySQL / MariaDB

Supports backtick identifiers, MySQL-specific functions (GROUP_CONCAT, IFNULL), and MariaDB extensions. The most widely deployed open-source RDBMS.

PostgreSQL

Supports dollar-quoting, RETURNING clauses, CTEs, window functions, JSONB operators, and the full feature set of the most advanced open-source database.

T-SQL (MSSQL)

Microsoft SQL Server syntax including TOP, square bracket identifiers, OUTPUT clauses, CROSS APPLY, OUTER APPLY, and system objects.

SQLite

Lightweight embedded database dialect. Useful for mobile apps, Electron apps, and local-first tools. Subset of SQL with some unique pragmas.

BigQuery

Google BigQuery SQL with backtick project.dataset.table identifiers, ARRAY/STRUCT types, UNNEST, QUALIFY, and partitioned table syntax.

Spark SQL / Hive

Distributed query engines used in big data pipelines. Support LATERAL VIEW, MAP/REDUCE hints, and partitioned I/O syntax.

PL/SQL (Oracle)

Oracle's procedural extension to SQL, including BEGIN/END blocks, cursors, ROWNUM/ROWID pseudocolumns, and Oracle-specific date arithmetic.

Snowflake / Redshift

Cloud data warehouse dialects with semi-structured data support (VARIANT, SUPER), COPY commands, and analytics-specific syntax.

Format vs Minify

Format (Beautify)

Expands a compressed or unformatted query into a multi-line, indented, human-readable form. Best for code review, debugging, and documentation.

Minify (Compress)

Collapses a formatted query into a single line with minimal whitespace. Useful for embedding SQL in code strings, reducing payload size, or obfuscating query structure.

Common Use Cases

Code Review

Normalize query formatting before committing to version control so diffs reflect logic changes rather than whitespace differences.

ORM Output Cleanup

ORMs like Hibernate, ActiveRecord, and Prisma often generate hard-to-read SQL. Format the logged query to understand what's being executed.

Legacy Query Migration

Clean up old, inconsistent SQL when migrating from one database system to another or refactoring stored procedures.

Documentation

Format queries for README files, blog posts, or internal wikis so readers can follow query structure without effort.

Query Debugging

Unminify a compressed SQL string from a log file or error report to identify exactly which clause caused the issue.

Interview Prep

Practice writing clean, consistently formatted SQL that meets professional coding standards expected in technical interviews.