About PostgreSQL Formatter
This page opens with the PostgreSQL dialect and a query that uses a WITH clause, a ::date cast, an interval, ILIKE and array_agg. The dialect understands PostgreSQL operators and keeps the :: cast tight. It is free, needs no sign-up and runs in your browser, so nothing you enter is uploaded.
PostgreSQL also has dollar-quoted strings, JSON operators such as ->> and numbered parameters like $1. Picking this dialect makes sure those are read as PostgreSQL syntax rather than as errors.
How to use PostgreSQL Formatter
- Paste your SQL into the box. The sample query is replaced as soon as you type.
- Choose the dialect that matches your database.
- Pick the keyword case and the indent width, or switch on Minify for a one-line version.
- Read the result. If the SQL cannot be parsed you get the first line of the error instead.
- Copy the result or download it as query.sql.
Features
- Nineteen dialect options, from standard SQL to cloud warehouses.
- Keyword case: UPPER, lower or kept as written.
- Indent by 2, 4 or 8 spaces, or a tab, with standard or tabular alignment.
- Minify: removes comments and collapses whitespace, leaving strings and quoted names untouched.
- Several statements at once, separated by blank lines.
- Copy and download as a .sql file.
- Formatting happens as you type, with a short delay.
Worked examples
with recent as (select id,email,created_at::date as signup_date from accounts where created_at>now()-interval '7 days') select r.signup_date,count(*) as sign... gives WITH / recent AS ( / SELECT / id, / email, / created_at::date AS signup_date / FROM / accounts / WHERE / created_at > now() - interval '7 days' / ) / SELECT / r.signup_date, / count(*) AS signups, / array_agg( / r.email / ORDER BY / r.id / ) AS emails / FROM / recent r / WHERE / r.email ILIKE '%@example.com' / GROUP BY / r.signup_date / ORDER BY / r.signup_date;
The WITH clause is laid out as its own block above the main select.
Privacy: how it works
- Your SQL is formatted by code running in this browser tab. It is not sent anywhere, and the formatter library is loaded only when you open this page.
Tips
- Pick the dialect before anything else: it decides how quoted names, functions and special operators are read.
- Format a query before a code review so the diff shows real changes instead of spacing.
- Upper-case keywords make the structure stand out; lower-case suits teams that prefer it. Pick one and keep it.
- If formatting fails, look at the first line of the error. A missing quote or bracket is the usual cause.
Frequently asked questions
Is it really free?
Yes. There is no price, no trial and no credit card. Ulkaa Tool does the work with your own device, so there is no server bill to pass on to you.
Do I need an account?
No. There is no sign-up and no login. Open the page and use it. An Ulkaa account is not needed for anything on this tool.
Does it run in my browser?
Yes. Your SQL are processed by code running in your browser tab, on your own device.
Is my data uploaded?
No. Your SQL are never sent to Ulkaa or to anyone else. You can check this yourself by watching the Network tab in your browser developer tools while you use the tool.
Does it format $1 style parameters?
Yes. With the PostgreSQL dialect numbered parameters are recognised and left in place.
More SQL Formatter pages
- SQL FormatterPaste SQL, pick a dialect and get readable, consistently indented code.
- MySQL FormatterBeautify MySQL queries with the MySQL dialect selected.
- SQLite FormatterBeautify SQLite scripts with several statements.
- T-SQL FormatterBeautify Microsoft SQL Server queries with the T-SQL dialect.
- BigQuery SQL FormatterBeautify GoogleSQL for BigQuery, including UNNEST and project.dataset.table paths.
- Snowflake SQL FormatterBeautify Snowflake queries, including the QUALIFY clause.
- Oracle SQL FormatterBeautify Oracle queries with the PL/SQL dialect.
- Amazon Redshift SQL FormatterBeautify Redshift queries, including LISTAGG and DATEADD.
- MariaDB SQL FormatterBeautify MariaDB queries with the MariaDB dialect selected.
- Lowercase SQL KeywordsFormat SQL with lower-case keywords and keep your names exactly as typed.
- SQL MinifierStrip comments and collapse whitespace into a compact query.