Format & beautify PostgreSQL SQL online
Format and beautify PostgreSQL SQL: consistent indentation, aligned clauses, uppercase keywords — and minified one-liners expanded back into readable code.
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.
Beautify minified PostgreSQL SQL
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.
Frequently asked questions
Does the formatter understand PostgreSQL-specific syntax?
Yes. The query is parsed against PostgreSQL grammar rather than generic SQL, so PostgreSQL-only constructs survive formatting: JSONB operators, :: casts, ILIKE and RETURNING.
What is the difference between formatting and beautifying PostgreSQL SQL?
Nothing — they are two names for the same operation. "Format" usually describes tidying SQL you wrote yourself; "beautify" usually describes expanding a minified or ORM-generated one-liner into readable lines. This page does both, with a worked example of each above.
Is my SQL uploaded anywhere?
No. Formatting runs entirely in your browser — the query never leaves your machine and nothing is stored on a server.
Is the PostgreSQL formatter free?
Yes: free, no account, no usage limit. Only the optional AI features — explain, optimize and dialect conversion — require signing in.