SQL Formatter (PostgreSQL)

This SQL formatter makes PostgreSQL queries and DDL easy to read: one clause per line, consistent keywords and indentation.

PostgreSQL

PostgreSQL

Waiting for input

What you get

How each result is checked

  1. Your SQL is parsed with the real PostgreSQL parser (libpg-query, compiled to WebAssembly).
  2. The formatted SQL is parsed again and its syntax tree compared with the original, so it means exactly the same thing.

What can't convert exactly

  • Comments are not part of the syntax tree, so the formatted output leaves them out.
  • Only PostgreSQL syntax is supported.

Questions

Can formatting change what my query does?

No. Both versions are parsed by PostgreSQL's own parser and must give identical syntax trees, statement by statement.

Is my data uploaded?

No. Everything runs in your browser, in a background worker. Nothing is sent to a server.

Does it format MySQL or SQL Server queries?

It is a PostgreSQL formatter: queries are read by PostgreSQL’s own parser, so PostgreSQL-specific syntax is understood exactly. Standard SQL that PostgreSQL accepts also works; MySQL- or SQL Server-only syntax is reported as an error.

How do I use the SQL Formatter (PostgreSQL) online?

Paste your input or open a file on the left. The result appears on the right as you type, already checked; copy or download it. Nothing is uploaded: the SQL Formatter (PostgreSQL) runs in your browser.