SQL Formatter

The CLI includes a SQL formatter for Snowflake and PostgreSQL. Formatting is semantic-preserving and idempotent, and supports scripting blocks, DDL, and DML.

Usage

# Format a file (Snowflake, default)
lexega-sql fmt query.sql

# Format PostgreSQL
lexega-sql fmt --dialect postgresql query.sql

# Format with a preset style
lexega-sql fmt query.sql -s compact

Configuration

Options are configured via .lexega.toml, auto-discovered from the input file's directory.

keyword_case = "upper"           # "upper", "lower", "title", "preserve"
identifier_case = "preserve"     # "upper", "lower", "preserve"
indent_style = { spaces = 2 }    # { spaces = N } or "tabs"
comma_style = "trailing"         # "trailing" or "leading"

Run lexega-sql fmt --help for all options.

Need Help?

Can't find what you're looking for? Check out our GitHub or reach out to support.