SQL Prettifier (Indent, Keywords Uppercase)
Reformat any SQL query for readability — newlines before major clauses (SELECT, FROM, WHERE, GROUP BY), indented subqueries, uppercase keywords. Works on most dialects: PostgreSQL, MySQL, SQLite, SQL Server, Oracle.
How to use the SQL Prettifier (Indent, Keywords Uppercase)
Paste a SQL query, choose the keyword case (uppercase, lowercase, or preserve) and the indent width, and the formatted query appears below with newlines before each major clause and indented subqueries. Copy the result.
Making SQL readable
SQL pulled from an application log, an ORM’s debug output, or a one-line string in source code arrives without any line breaks, so a join with three subqueries reads as an unbroken wall of text where the clause boundaries are invisible. Reading or reviewing a query in that state means mentally parsing where each SELECT, FROM, WHERE, and JOIN begins.
This reformats a query with newlines before every major clause, indented subqueries, and your choice of keyword case — uppercase, lowercase, or preserved — across the common dialects (PostgreSQL, MySQL, SQLite, SQL Server, Oracle). It is the lightweight everyday formatter; the SQL formatter covers more dialects (BigQuery, Snowflake, T-SQL) and can also minify, and to make sense of a query plan rather than the query itself, use the Postgres EXPLAIN formatter.
Common use cases
- Read a logged query — break a one-line ORM query into clauses.
- Review a join — indent nested subqueries to see the structure.
- Normalise keyword case — uppercase or lowercase keywords consistently.
- Tidy before commit — format an inline SQL string for a readable diff.
- Match your style — choose 2 or 4 space indentation.