Advertisement

PostgreSQL Formatter

Paste a PostgreSQL query and get clean formatting with uppercase keywords and indented subqueries. Knows Postgres specifics like ILIKE, RETURNING, ON CONFLICT, SERIAL types and type casts.

PostgreSQL

Paste a PostgreSQL query below.

Advertisement

How the PostgreSQL formatter works

The tool masks strings and comments, then uppercases a Postgres aware keyword list covering ILIKE, RETURNING, ON CONFLICT, SERIAL, TIMESTAMPTZ and more. Clauses break onto their own lines, JOINs and their ON conditions are stacked, and nested selects indent by parenthesis depth.

Built for real Postgres code

UPSERTs with ON CONFLICT DO NOTHING, INSERTs with RETURNING id, and case insensitive searches with ILIKE all format cleanly. Type casts like price::numeric pass through untouched because only known keywords are uppercased.

PostgreSQL Formatter FAQs

Does it handle RETURNING clauses?
Yes. RETURNING is a recognized keyword, so INSERT, UPDATE and DELETE statements with RETURNING id keep the clause on its own formatted line.
What about dollar-quoted function bodies?
Dollar-quoted blocks such as $$ ... $$ are treated as plain text, so keywords inside a plpgsql function body may be uppercased. Review function bodies after formatting.
Does it support ON CONFLICT upserts?
Yes. ON CONFLICT, DO NOTHING and DO UPDATE are in the keyword list and are uppercased, with the conflict target kept on the same logical line.
Are JSON operators preserved?
Yes. Operators like ->, ->> and @> contain no keyword text, so JSON queries pass through with only clause level reformatting applied.
Is my query sent to a server?
No. Formatting runs entirely in your browser, so queries with table names or business logic never leave your device.
Advertisement