SQLFormatter
FormatterConvertPricingDocsGet Pro
Beautifier · PostgreSQL

Beautify PostgreSQL SQL online

Beautify minified, single-line PostgreSQL SQL into clean, readable, properly indented queries. Turn crushed output from logs, ORMs or dbt into something you can read, diff and review.

1Paste your PostgreSQL query into the editor.
2Press Format — or ⌘↵.
3Copy clean, highlighted SQL.
Open formatter
before
WITH t AS(SELECT user_id,sum(amount)total FROM payments WHERE status='paid' GROUP BY user_id)SELECT u.email,t.total FROM users u JOIN t ON t.user_id=u.id WHERE t.total>1000 ORDER BY t.total DESC;
PostgreSQL
WITH
  t AS (
    SELECT
      user_id,
      sum(amount) total
    FROM
      payments
    WHERE
      status = 'paid'
    GROUP BY
      user_id
  )
SELECT
  u.email,
  t.total
FROM
  users u
  JOIN t ON t.user_id = u.id
WHERE
  t.total > 1000
ORDER BY
  t.total DESC;

Why beautify PostgreSQL?

Minified Postgres — CTEs and subqueries crushed onto one line by an ORM or a copy-paste from psql — becomes unreadable fast. Beautifying it puts each CTE, JOIN and clause on its own indented line so the query's shape is visible again.

That readable layout is what makes a query reviewable: a clean, multi-line Postgres query produces a sane git diff, so teammates can actually see what changed in a pull request.

All SQL formatters & beautifiers

Format PostgreSQLBeautify PostgreSQL
Format MySQLBeautify MySQL
Format T-SQLBeautify T-SQL
Format SQLiteBeautify SQLite
Format BigQueryBeautify BigQuery
Format OracleBeautify Oracle
Format SnowflakeBeautify Snowflake
Format RedshiftBeautify Redshift