OpenReplay Logo
12k

SQL formatter

Format, beautify, and minify SQL for any major dialect — processed locally in your browser, so your queries never leave your machine.

Keyword case
Processed locally

About this tool

A SQL formatter normalizes the whitespace, indentation, and keyword casing of a query without changing what it does. It parses your SQL into tokens and re-emits them with consistent line breaks and two-space indentation, so clauses like SELECT, JOIN, WHERE, and GROUP BY line up predictably. This tool supports Standard SQL plus dialect-specific rules for PostgreSQL, MySQL, SQLite, BigQuery, Snowflake, and SQL Server, and lets you force keywords to UPPER, lower, or preserve their original case.

Use it to clean up a one-line query copied from an ORM log, make a dense generated statement reviewable in a pull request, or standardize casing across a team's SQL files. The Minify button does the reverse — it collapses a formatted query back onto a single line and strips comments while leaving the contents of quoted strings untouched — which is handy for pasting a compact query into a config value or a code string.

Formatting only rearranges whitespace and casing — it never validates that your query is correct against a real schema, and minify deliberately preserves the spacing inside quoted string literals.

Frequently asked questions

Which SQL dialects does this formatter support?

It supports Standard SQL, PostgreSQL, MySQL, SQLite, BigQuery, Snowflake, and SQL Server (Transact-SQL). Each dialect applies its own keyword and syntax rules so the output matches that engine's conventions.

Does formatting change what my SQL query does?

No. Formatting only adjusts whitespace, indentation, and keyword casing — the tokens and logic of the query are unchanged, so a formatted query runs identically to the original.

Does minifying SQL remove the spaces inside my string values?

No. Minify collapses whitespace and strips comments only outside of quoted strings, so a literal like 'a b' keeps its inner spaces and embedded comment-like text is left intact.