DLH.io SQL Optimizer
A powerful VS Code extension for formatting and optimizing SQL queries using the @dlh.io/dlh-sql-formatter package.
Features
Open a dedicated panel to paste and format SQL with full control over all formatting options.
- Command:
DLH SQL: Open SQL Formatter Panel
- Keyboard Shortcut:
Ctrl+Shift+Q (Windows/Linux) / Cmd+Shift+Q (Mac)

Format individual SQL queries or entire SQL files with a single command.
- Format Selection/File:
DLH SQL: Format SQL Query
- Format Each Query:
DLH SQL: Format Each SQL Query in File
- Keyboard Shortcut:
Ctrl+Shift+F (Windows/Linux) / Cmd+Shift+F (Mac) in SQL files
Clickable buttons appear above each SQL query, allowing you to format or optimize queries with a single click.

- ⚡ Optimize SQL - Optimize the query (coming soon)
- 📄 Format SQL - Format the query using your configured options
CodeLens works in:
- SQL files (
.sql, .mysql, .postgres, etc.)
- Embedded SQL in TypeScript, JavaScript, Python, Java, C#, Go, Rust, PHP, Ruby
Supported SQL Dialects
- Standard SQL
- BigQuery
- DB2 / DB2i
- Hive
- MariaDB
- MySQL
- N1QL (Couchbase)
- PL/SQL (Oracle)
- PostgreSQL
- Amazon Redshift
- SingleStoreDB
- Snowflake
- Spark SQL
- SQLite
- Transact-SQL (SQL Server)
- Trino
Configuration Options
Configure formatting options in VS Code settings (Preferences > Settings > Extensions > DLH SQL Optimizer):
| Option |
Default |
Description |
language |
sql |
SQL dialect to use |
tabWidth |
2 |
Spaces per indentation level |
useTabs |
false |
Use tabs instead of spaces |
keywordCase |
upper |
Case for keywords (preserve/upper/lower) |
identifierCase |
preserve |
Case for identifiers |
dataTypeCase |
upper |
Case for data types |
functionCase |
upper |
Case for function names |
indentStyle |
standard |
Indentation style |
commaPosition |
trailing |
Position of comma |
logicalOperatorNewline |
before |
AND/OR placement |
expressionWidth |
50 |
Max inline expression width |
linesBetweenQueries |
2 |
Blank lines between queries |
denseOperators |
false |
Remove operator spacing |
newlineBeforeSemicolon |
false |
Semicolon on new line |
enableCodeLens |
true |
Show CodeLens buttons |
Usage Examples
- Open Command Palette (
Ctrl+Shift+P)
- Run "DLH SQL: Open SQL Formatter Panel"
- Paste your SQL in the input area
- Adjust formatting options as needed
- Click "Format SQL" or press
Ctrl+Enter
- Copy the result or insert directly into your editor
Using CodeLens
- Open a SQL file or a file with embedded SQL
- Look for the "⚡ Optimize SQL" and "📄 Format SQL" buttons above queries
- Click to format or optimize the specific query
Keyboard Shortcuts
| Shortcut |
Command |
Ctrl+Shift+Q |
Open SQL Formatter Panel |
Ctrl+Shift+F |
Format SQL (in SQL files) |
Installation
From VSIX
- Download the
.vsix file
- Open VS Code
- Run "Extensions: Install from VSIX..." from Command Palette
- Select the downloaded file
From Source
git clone https://github.com/datalakehouse/dlh-sql-optimizer-vscode.git
cd dlh-sql-optimizer-vscode
npm install
Then press F5 to run the extension in development mode.
To get the .vsix file and install it as extension, use the command below and follow vsix installation.
vsce package
In case of errors run npm run clean and then run the above command.
Requirements
- VS Code 1.75.0 or higher
- Node.js 16+ (for development)
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Support