Home / Companies / Cockroach Labs / Blog / Post Details
Content Deep Dive

sqlfmt: A SQL formatter for writing prettier SQL

Blog post from Cockroach Labs

Post Details
Company
Date Published
Author
Matt Jibson
Word Count
1,721
Language
English
Hacker News Points
207
Summary

sqlfmt is an online SQL formatter that aims to beautifully format SQL statements by understanding all CockroachDB syntax, attempting to use available horizontal space in the best way possible, and maintaining visual alignment regardless of editor configuration. It was designed with a focus on using available space efficiently and adapting to the complexity of the query. The tool is based on a paper describing an algorithm for efficient document layout with multiple possible layouts, initially implemented in Haskell and later converted into Go. sqlfmt is not highly customizable and aims to remove options over time as it evolves.