sqlalign is a SQL formatter that produces columnar, aligned output — and re-parses every statement it writes to prove it did not change what the SQL means.
In:
select cust.customer_id, cust.email, sum(ord.total) as lifetime_value from customers cust inner join orders ord on ord.customer_id = cust.customer_id where ord.order_date >= '2026-07-01' group by cust.customer_id, cust.email;
Out:
SELECT cust.customer_id
, cust.email
, SUM(ord.total) AS lifetime_value
FROM customers cust
INNER JOIN orders ord ON ord.customer_id = cust.customer_id
WHERE ord.order_date >= '2026-07-01'
GROUP BY cust.customer_id
, cust.email;
The guarantee#
Every statement is re-parsed after formatting and compared against the input
as a syntax tree. If the output would differ semantically — or if the engine
does not fully model the construct — that statement is passed through
byte-identical with a warning instead. A passthrough is not a failure, and the
run still exits 0.
Pages#
Getting started
Install it, run it on a file, wire it into a pre-commit hook.
Configuration
The config file, the CLI flags that override it, and the presets.
Settings reference
Every setting, with its default and the same SQL rendered under each value.
The house style
What the output looks like, and the rule behind each decision.
CLI reference
Every flag, its default, and what it does.
Dialects
Postgres, Redshift and T-SQL — what each supports and what each declines.
Architecture
The layout IR, the alignment resolver, and the safety model.
FAQ
Why it declines, why it will not fix your SQL, and how it compares.