Database Daily
wolfsrudel's profile
Tobias Wolf@wolfsrudel•Aug 11
2.1K
Post cover image

Introducing sqlfmt: an SQL gofmt-style formatter

Avatar of planet-postgresqlPlanet PostgreSQL•From postgr.es•Aug 11•5m read time

sqlfmt is a new opinionated SQL formatter inspired by gofmt, implementing the 'river alignment' style from The Art of PostgreSQL. It right-pads all clause keywords (select, from, where, group by, etc.) to the same column at each nesting level, creating a vertical river with expressions flowing to the right. The tool uses a tokenizer rather than an AST for robustness and comment preservation. It ships with a CLI mirroring gofmt's interface (-w, -l, -d flags), editor plugins for Emacs and Vim/Neovim, and a WebAssembly-powered web formatter (~130 KB compressed). Install via `go install github.com/dimitri/sqlfmt/cmd/sqlfmt@latest`. The style enforces lowercase keywords, trailing commas, and and/or at line starts. A correctness oracle using pganalyze/pg_query_go verifies formatting never changes query semantics.

234.7K Impressions3 Comments
wolfsrudel's user avatar
Tobias Wolf
@wolfsrudel
Joined May 12. 2022
2.1K

nix develop .#lima --command 'nu -c "dagger -m automation call pipeline export benefit"'

Would you recommend this post?

Copy link
WhatsApp
Facebook
X
New Squad
  • © 2026 Daily Dev Ltd.
  • Guidelines
  • Explore
  • Tags
  • Sources
  • Squads
  • Leaderboard