PostgreSQL Formatter Online
Format PostgreSQL queries with dialect support for JSONB operators, casts and Postgres functions. Paste SQL, choose PostgreSQL and beautify.
Part of the free SQL Formatter. Runs in your browser — nothing is uploaded.
PostgreSQL Formatter Online
PostgreSQL adds syntax standard SQL formatters can mangle, such as the -> and ->> JSONB operators, @> containment and :: casts. Select the PostgreSQL dialect in the tool and those are formatted correctly.
Worked example: JSONB operators and a cast in PostgreSQL
Input
select id, data->>'name' as name, created_at::date as day from events where data @> '{"type":"signup"}' order by created_at desc limit 20;Formatted PostgreSQL
SELECT
id,
data ->> 'name' AS name,
created_at::date AS DAY
FROM
events
WHERE
data @> '{"type":"signup"}'
ORDER BY
created_at DESC
LIMIT
20;Practical tip
Set the dialect to PostgreSQL before formatting. Using Standard SQL may add stray spaces inside operators like ->> or ::.
How to use this SQL Formatter
- 1Use the live tool above — it runs entirely in your browser and never uploads your data.
- 2Paste the sample from the worked example, or use your own input.
- 3Copy the result, then adapt the same steps in your editor, script, or pipeline.
PostgreSQL Formatter Online FAQs
Does it support Postgres JSONB operators?
Yes. With the PostgreSQL dialect selected, operators like ->, ->>, #>, @> and the :: cast are kept intact.
Can I format a psql script with several statements?
Yes. Paste multiple statements separated by semicolons and each is formatted in turn.
More SQL Formatter pages
- Format SQL Query OnlineFormat SQL queries online with uppercase keywords and clean indentation. Paste a one-line query and get readable SQL instantly. Free and private.
- MySQL Query FormatterFormat MySQL queries online with backtick identifiers and MySQL functions handled correctly. Paste your query, pick MySQL and beautify it.
- SQL Server (T-SQL) FormatterFormat T-SQL for Microsoft SQL Server. Handles TOP, schema-qualified names and bracket identifiers. Paste your query and beautify it online.
- Beautify SQL JOIN QueriesFormat multi-table SQL JOIN queries so every join and ON condition sits on its own line. Paste your query and read the relationships clearly.
- Format Long SQL SELECT StatementsFormat SELECT statements with dozens of columns. Each column lands on its own line so wide queries are easy to read, edit and review.
- BigQuery SQL FormatterFormat Google BigQuery SQL with backtick project.dataset.table names. Choose the BigQuery dialect and beautify analytics queries online.
- Snowflake SQL FormatterFormat Snowflake SQL with database.schema.table names and Snowflake functions. Pick the Snowflake dialect and beautify queries online.
- Format SQL INSERT StatementsFormat multi-row INSERT INTO statements so each VALUES tuple sits on its own line. Easier to review seed data and migrations.
- SQL CTE FormatterFormat SQL queries that use WITH common table expressions. Each CTE is indented clearly so multi-step queries are easy to follow. Free and private.