SQLFormatter
FormatterConvertPricingDocsGet Pro
Formatter · PostgreSQL

Format PostgreSQL SQL online

Reformat PostgreSQL queries against PostgreSQL's own grammar: consistent indentation, aligned clauses and uppercase keywords. Paste one-line or ORM-generated SQL and get structured, reviewable output.

1Paste your PostgreSQL query into the editor.
2Press Format — or ⌘↵.
3Copy clean, highlighted SQL.
Open formatter
before
select u.id,u.email,u.data->>'plan' as plan from users u where u.data->>'active'='true' and u.email ilike '%@acme.com' order by u.created_at desc limit 25;
PostgreSQL
SELECT
  u.id,
  u.email,
  u.data ->> 'plan' AS plan
FROM
  users u
WHERE
  u.data ->> 'active' = 'true'
  AND u.email ILIKE '%@acme.com'
ORDER BY
  u.created_at DESC
LIMIT
  25;

Why format PostgreSQL?

PostgreSQL adds syntax no generic beautifier handles cleanly: the JSONB accessors -> and ->>, :: casts, ILIKE, RETURNING clauses and array literals. The formatter parses against Postgres grammar so these stay intact instead of being mangled into keywords.

It also keeps dollar-quoted strings ($$ … $$) and CTEs structurally correct — the exact constructs that make hand-formatting Postgres tedious.

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