Dev / Text & Code / SQL Formatter

PostgreSQL Formatter — Format PostgreSQL Queries Online Free

Format, minify, validate SQL · Auto-detect dialect · AI explain & optimize

💡

PostgreSQL Formatter formats PostgreSQL queries with support for SERIAL, RETURNING, JSONB, ILIKE, UUID, ARRAY, LATERAL, WITH RECURSIVE, VACUUM, ANALYZE, and other PostgreSQL-specific features. AI explain and optimize your PostgreSQL queries instantly.

or drag & drop .sql / .txt anywhere · max 5MB
Ctrl+M to cycle
Dialect
✦ AI
INPUT
Indent
Keywords
OUTPUT
Formatted SQL will appear here…
In: 0 chars · 0 lines·Out: 0 chars · 0 B·0ms
0 uses · 0 secondsmin saved

About SQL Formatter

PostgreSQL Formatter formats PostgreSQL queries with support for SERIAL, RETURNING, JSONB, ILIKE, UUID, ARRAY, LATERAL, WITH RECURSIVE, VACUUM, ANALYZE, and other PostgreSQL-specific features. AI explain and optimize your PostgreSQL queries instantly.

Frequently Asked Questions

What PostgreSQL-specific keywords are supported?

Supported PostgreSQL keywords include: SERIAL, BIGSERIAL, RETURNING, ILIKE, JSONB, UUID, ARRAY, LATERAL, WITH RECURSIVE, TABLESPACE, VACUUM, ANALYZE, EXPLAIN ANALYZE, and PostgreSQL-specific operators.

Does it support PostgreSQL CTE (WITH clause)?

Yes. Common Table Expressions including WITH RECURSIVE are recognized and formatted — each CTE gets its own indented block, and the final SELECT is formatted separately.

What about PostgreSQL window functions?

All standard window functions are supported: ROW_NUMBER(), RANK(), DENSE_RANK(), LAG(), LEAD(), FIRST_VALUE(), LAST_VALUE() with OVER(), PARTITION BY, and frame specifications.

Can it format PostgreSQL JSONB queries?

The formatter handles JSONB queries as SQL text — it formats the SQL structure correctly. JSONB operators (->, ->>, @>, ?|) are preserved as-is within the formatted output.

Does AI Optimize work for PostgreSQL?

Yes. AI Optimize provides PostgreSQL-specific recommendations — using partial indexes, leveraging EXPLAIN ANALYZE output patterns, optimizing CTE usage, and recommending appropriate PostgreSQL index types (GIN, GiST, BRIN).

Ctrl+Enter FormatCtrl+M Cycle ModeCtrl+L ClearCtrl+S Download .sqlCtrl+Shift+C CopyF FullscreenP Pin? Help