PostgreSQL SQL Formatter
This page selects the PostgreSQL dialect before your query is formatted. It recognizes dollar-quoted text such as $tag$...$tag$, :: casts, $1 parameters and PostgreSQL query clauses. Load the dialect sample for a working cast, dollar literal and JSON-field query, or paste your own statements. Adjacent string literals keep their source gaps so a newline used for PostgreSQL string concatenation is not flattened away.
Preparing current SQL output…
- Output
- Keywords
- Indent
Formatting arranges SQL statements for the selected dialect. It does not execute queries, validate database objects or optimize performance. Stored procedures and client batch directives are outside this formatter’s scope. SQL stays in this browser. Your input and settings are remembered in local browser storage; Start over clears them.
Common questions
- Does it format PL/pgSQL functions or stored procedures?
- No. This workflow formats PostgreSQL SQL statements, not a complete PL/pgSQL procedural program. Dollar-quoted bodies remain literal text; their internal code is not reformatted.
- Does it use PostgreSQL to validate the query?
- No PostgreSQL server or database is connected. The formatter handles dialect syntax for layout, while database-version compatibility and query validity must be checked on the target database.
- Are casts, parameters and dollar strings kept?
- Yes. The preset and tests cover :: casts, $1 parameters and tagged dollar-quoted literals. Quoted literal text is preserved; keyword case and whitespace outside literals control the layout.
Formats SQL statements for the selected dialect; it does not execute SQL, check database objects, optimize queries or validate a complete SQL grammar. Stored procedures and client batch directives are outside its scope. Minify preserves comments and quoted values and can retain meaningful newlines.