PostgreSQL SQL Formatter

Paste a Postgres query and get clean, consistently indented SQL. Numbered $1 placeholders from prepared statements are detected so you can fill them in, and Postgres-specific syntax such as JSONB operators, casts and dollar-quoted function bodies is preserved.

PostgreSQL syntax it handles

A generic formatter mangles dialect-specific syntax or refuses it outright. These are the PostgreSQL constructs this formatter is tested against.

$1, $2

Numbered placeholders from prepared statements are detected and can be filled in to produce a runnable query.

payload->>'key'

JSON and JSONB operators are left exactly as written.

value::type

Cast syntax is never mistaken for a :name parameter.

$$ ... $$

Dollar-quoted function bodies are treated as literals, so keywords inside them are not reformatted.

WITH ... AS

Every CTE's WHERE clause is listed separately and can be edited on its own.

OVER (PARTITION BY ...)

Window functions and their frames are formatted without breaking the clause apart.

PostgreSQL formatter FAQ

Does it handle $1 placeholders from prepared statements?

Yes. Postgres numbered placeholders are detected and listed in the Parameters panel. Fill each one and switch the output to filled SQL to get a query you can paste straight into psql.

Will it break my ::casts or JSONB operators?

No. Casts are distinguished from :name parameters, and JSON/JSONB operators such as -> and ->> pass through unchanged.