PostgreSQL SQL Formatter
Free online PostgreSQL SQL formatter. Beautify and indent PostgreSQL queries with support for CTEs, window functions, JSONB operators, ON CONFLICT, and RETURNING clauses.
What is PostgreSQL?
PostgreSQL (also known as Postgres) is a powerful, open-source object-relational database management system with over 35 years of active development. It is ACID-compliant, supports advanced data types including JSONB, arrays, and custom types, and provides robust support for complex queries, window functions, and CTEs.
PostgreSQL is the go-to database for applications that need reliability, data integrity, and advanced SQL features. It powers everything from small web applications to large data warehouses, and its extensibility makes it a popular base for specialized databases like TimescaleDB (time-series) and PostGIS (geospatial).
When formatting PostgreSQL SQL, using the PostgreSQL dialect ensures that Postgres-specific syntax — dollar-quoted strings, JSONB operators (->>, @>), ON CONFLICT, RETURNING, and LATERAL joins — is handled correctly and laid out clearly.
Frequently asked questions
Does the PostgreSQL formatter handle dollar-quoted strings?
Yes. PostgreSQL's dollar-quoting syntax (e.g. $$ or $function$) is correctly parsed and preserved. Dollar-quoted blocks are treated as string literals so their contents are not reformatted.
Will it format ON CONFLICT DO UPDATE (upsert) correctly?
Yes. PostgreSQL-specific clauses like ON CONFLICT DO UPDATE, ON CONFLICT DO NOTHING, RETURNING, and LATERAL joins are all understood and indented correctly.
Does it format CTEs and window functions?
Absolutely. WITH clauses, WITH RECURSIVE CTEs, and window functions using OVER(), PARTITION BY, and ROWS BETWEEN are formatted with clear structure, making complex analytical queries much easier to read.
Are JSONB operators like ->> and @> preserved?
Yes. PostgreSQL-specific operators including JSONB path operators (->, ->>, #>, #>>), containment operators (@>, <@), and full-text search operators (@@) are preserved exactly as written.
Try Sequel
Query your database in plain English.
Connect your database and get instant answers without writing SQL. Free for up to 3 seats — no credit card required.
Get started free