SQL Formatter & Format SQL on Save

SQL Formatter & Format SQL on Save: PostgreSQL, MySQL, T-SQL, PL/SQL (Zovo), a VS Code extension by Zovo

Format SQL in VS Code without breaking it. Free, no sign-in, works offline.

Install in VS CodeOpen the Marketplace page

Free, MIT license. Needs VS Code 1.90.0 or newer. Extension ID zovo.zovo-sql-formatter, version 0.2.1.

A PostgreSQL function and a query formatted in VS Code. The $$ body, the comments and the strings are unchanged, and the status bar shows the PostgreSQL dialect.

Questions people ask

Is SQL Formatter & Format SQL on Save free?

Yes. SQL Formatter & Format SQL on Save is free and MIT licensed.

How do I install SQL Formatter & Format SQL on Save?

Click "Install in VS Code" above, or search for zovo.zovo-sql-formatter in the Extensions view.

Use it

``json "[sql]": { "editor.formatOnSave": true, "editor.defaultFormatter": "zovo.zovo-sql-formatter" } ``

When it does not format

A warning in VS Code: "Not formatted: unterminated string at line 2. The file is unchanged." with buttons Go to Line, Pick Dialect and Format the Rest.

The file is left as it is when:

Format the Rest formats every statement it can read and keeps the others exactly as written. With format on save, the same message shows only once a minute and then moves to the status bar.

Stored procedures

A T-SQL stored procedure with BEGIN TRY and BEGIN CATCH blocks, indented by block.

Plain statements inside a procedure are formatted as usual. Control lines go on their own lines and the body is indented by block. MySQL DELIMITER sections, T-SQL GO batches and Oracle / lines are kept.

Why this one

Reviews of two popular SQL formatter listings report these problems. Each one has a test in this repository.

ReviewWhat this extension doesTest
"It doesn't work for pl/sql. $$ becomes $ $" (reviews, 2025-04 and 2024-10)$$, $tag$ and $BODY$ bodies are kept byte for byte in every dialect$$ bodies stay byte for byte
"Turns DELIMITER $$ into DELIMITER $ $" (review, 2023-12)DELIMITER lines are kept, and each statement in the section is formatted on its ownDELIMITER $$ lines ... are kept
"Space between N ' not allowed" (review, 2023-06)N'...', E'...', X'...' and q'[...]' strings are never splitN'...' strings keep the N
"will format commented out code's comma ... and error the code" (review, 2026-03)Comments are compared before and after; a comma in a comment is never moved, also with leading commascommented-out code with commas
"does not appear to handle escaped (square brackets) column names when they contain spaces" (review, 2026-01)[first name], [x]]y] and ` full name ` are kept as written[bracket names] with spaces
"Crashed vscode and lost $$$" (review, 2025-08)Formatting runs in a worker thread with a time limit; a failure leaves the file unchangedthe time limit stops the worker, 10,000 nested parentheses are refused
"Not good at all with procedures or functions. Indents at the wrong place." (review, 2024-09)Procedures, functions, triggers and packages are indented by blockprocedures are indented by block, PL/SQL package body
"Doesn't work for postgre" (review, 2026-09)20 dialects with detection from the file and its textthe text picks the dialect

This extension uses the open source sql-formatter library (MIT) for plain statements. The checks, the dialect detection, the procedure layout and the client-line handling are its own.

Settings

SettingDefaultWhat it does
sqlFormatter.dialectautoDialect for all files
sqlFormatter.keywordCaseupperupper, lower or preserve
sqlFormatter.dataTypeCase, sqlFormatter.functionCasepreserveCase of data types and function names
sqlFormatter.commaPositiontrailingtrailing (a,) or leading (, b)
sqlFormatter.maxLineWidth60Lists shorter than this stay on one line
sqlFormatter.indentStylestandardstandard, tabularLeft or tabularRight
sqlFormatter.useEditorIndenttrueUse the editor's tab size and tabs or spaces
sqlFormatter.linesBetweenQueries1Empty lines between statements
sqlFormatter.logicalOperatorNewlinebeforeAND and OR at the start or the end of a line
sqlFormatter.procedureLayouttrueIndent procedures by block
sqlFormatter.maxFileSizeMB16Largest file to format as a whole
sqlFormatter.timeLimitSeconds30Stop and leave the file unchanged after this time
sqlFormatter.threads0Threads for files of 256 KB and up (0 picks up to 4)

Privacy

No network access, no telemetry, no account. The extension reads only the file you format.

License

MIT. The bundled sql-formatter library is MIT licensed (see vendor/sql-formatter.LICENSE).

Guides

Install SQL Formatter & Format SQL on Save

Click the button to open VS Code and install it, or press Ctrl+P (Cmd+P on macOS) in VS Code and run ext install zovo.zovo-sql-formatter.

Free, MIT license. Needs VS Code 1.90.0 or newer. Extension ID zovo.zovo-sql-formatter, version 0.2.1.

Source code and issues are on GitHub.

All our VS Code extensions

Support this work

If this extension saves you time, you can support the work on GitHub Sponsors. Monthly tiers start at $5, and one-time tiers start at $15. Sponsorship is optional, and the tool works the same without it.

Need your format supported?

Open a format request with a sample file, and I reply there whether it can be done. For USD 299 once, through this GitHub Sponsors tier, I add your file format or a missing feature to this extension, with tests, within 7 days.