SQL Prettify

Format and beautify SQL queries for readability.

Paste a query — minified, single-line, or one a colleague pasted from an ORM log — and get a clean, indented version with each clause on its own line and keywords consistently cased. Joins line up, predicates stack, and large queries become readable.

Common use cases: cleaning up ORM-generated SQL before pasting into a bug report, prepping migrations for code review, formatting analytics queries for documentation, and getting a quick visual sense of how complex a query really is.

Input SQL

Formatted SQL

Frequently asked questions

Which SQL dialect does the formatter assume?
It targets a portable ANSI/standard SQL with handling for the most common dialect-specific keywords (PostgreSQL, MySQL, SQL Server, SQLite, BigQuery, Snowflake). Most queries format cleanly without you choosing a dialect.
Will formatting change what my query does?
No. The tool only changes whitespace, line breaks and keyword casing — never the tokens, identifiers or order. The semantics of the query are preserved exactly.
Why are my comments getting moved around?
SQL formatters re-flow line breaks, which can shift a trailing -- comment onto its own line. Block /* … */ comments inside expressions are preserved in place. If a comment must stay glued to a specific token, prefer the block form.
Can I use this on stored procedures or migrations?
Yes — DDL (CREATE TABLE, ALTER TABLE), DML and procedural blocks all format. For very long migration files, format in chunks if your browser feels sluggish.
Does my query leave my browser?
No. Formatting runs entirely client-side. Paste production queries safely — nothing is transmitted.