Format SQL in VS Code without losing work. Every format is checked: SQL Format Desk re-tokenizes its own output and compares it to your original (ignoring only whitespace and keyword case). If anything would be dropped or changed, it aborts and changes nothing.
Features (Free)
- Format Document and Format Selection (also works as the standard VS Code formatter for
sql files, including Format on Save)
- 6 dialects + generic: T-SQL (SQL Server), PostgreSQL, PL/SQL (Oracle), MySQL, BigQuery, SQLite, and Generic SQL
- Auto-detect dialect: setting → language id → file extension (
.tsql, .pgsql, .pls, .mysql, .bq…) → content heuristics (GO, [brackets], $$, ::, VARCHAR2, backticks, QUALIFY, PRAGMA…)
- Status bar shows the detected dialect; click it to override for the current file
- Preview diff before apply for the SQL Format Desk commands (side-by-side diff, then Apply / Discard)
- Round-trip guard: abort with a message instead of corrupting your query
- Options: indent (spaces, tab, or follow editor), keyword case (upper / lower / preserve), comma position (trailing / leading)
- 100% offline: no network requests, no telemetry, no child processes, no webview
Commands
| Command |
What it does |
| SQL Format Desk: Format Document (Safe) |
Format the whole file (with preview if enabled) |
| SQL Format Desk: Format Selection (Safe) |
Format the selection only |
| SQL Format Desk: Select Dialect |
Override dialect for this file (or back to Auto) |
Settings
| Setting |
Default |
|
sqlFormatDesk.dialect |
auto |
auto, sql, transactsql, postgresql, plsql, mysql, bigquery, sqlite |
sqlFormatDesk.indent |
2 |
1–8, "tab", or "editor" |
sqlFormatDesk.keywordCase |
upper |
upper, lower, preserve |
sqlFormatDesk.commaPosition |
after |
after (trailing) or before (leading) |
sqlFormatDesk.previewBeforeApply |
true |
Diff + confirm for the SQL Format Desk commands |
sqlFormatDesk.showStatusBar |
true |
Show detected dialect |
Known limits
- Stored procedure / function bodies are not reformatted statement-by-statement (upstream engine limitation). The guard prevents damage; worst case you'll see an abort message.
- Detection heuristics can be wrong on very short queries — click the status bar to pick the dialect.
- Format Document / Format on Save apply directly (no preview); the guard still runs.
Pro (planned)
A paid Pro add-on is planned: procedure/function body formatting, a shared team .sqlformat.json, SQL inside JS/Python/PHP strings, and lint hints. Not available yet.
Privacy
Runs entirely on your computer. No network, no data collection.
Support
Bugs and ideas: bhamlefty@gmail.com · https://zecro-sql-format-desk.pages.dev/
Engine: sql-formatter (MIT), bundled. See THIRD-PARTY-NOTICES.md.
© 2026 Zecro LLC, Washington, USA.
| |