SQL Formatter

Paste SQL below to format, minify, or change keyword casing.

Why format SQL?

Raw SQL queries are often written as dense single-line strings embedded in application code, generated by ORMs, or extracted from database logs. Formatting them with consistent indentation, line breaks, and keyword casing makes them dramatically easier to read, review, and debug. A well-formatted query lets you spot missing JOIN conditions, misplaced WHERE clauses, and subquery boundaries at a glance.

SQL dialects

While SQL has an ANSI standard, every database engine extends it with proprietary syntax. PostgreSQL adds CTEs with MATERIALIZED hints, MySQL uses backtick quoting and LIMIT syntax, SQLite has a more limited type system, and MariaDB adds its own extensions on top of MySQL. This formatter understands each dialect's specific keywords and syntax rules so that formatting does not break dialect-specific constructs.

Minification

The minify option strips all unnecessary whitespace, reducing a formatted query to a single compact line. This is useful when embedding SQL in URLs, log messages, or configuration fields where space is limited. It also helps when comparing two queries for logical equivalence by removing formatting differences.

Keyword casing

The uppercase keywords option converts SQL reserved words like SELECT, FROM, WHERE, and JOIN to uppercase while leaving table names, column names, and literals unchanged. This convention, common in SQL style guides, improves readability by making the query structure stand out from the data it references.

Privacy

This tool runs entirely in your browser using the sql-formatter library. No queries are sent to any server. Your input stays on your machine.

ectoplasma.org ยท free tools