Open files in VS Code and Cursor / Code and APIs

Format SQL in VS Code

VS Code colors SQL but has no SQL formatter built in, so Format Document says there is no formatter for 'sql' files. Install the free SQL Safe Formatter by Zovo, then press Shift+Alt+F (Shift+Option+F on macOS). It picks the dialect for you (PostgreSQL, MySQL, T-SQL, PL/SQL and 16 more) and checks the result token by token. If anything other than whitespace or keyword case would change, the file stays as it is.

Install in VS CodeMarketplace pageOpen VSX (Cursor, Windsurf, VSCodium)JetBrains IDEs

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

Also free from Zovo: SQLite Editor & Viewer, VS Code Marketplace · Open VSX (Cursor, Windsurf).

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
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.

Steps in VS Code

  1. Install SQL Safe Formatter from the Marketplace, or press Ctrl+P (Cmd+P on macOS) and run ext install zovo.zovo-sql-formatter.
  2. Press Shift+Alt+F (Shift+Option+F on macOS), or right-click and choose Format Document. If VS Code asks which formatter to use, pick SQL Safe Formatter.
  3. To format part of a file, select it and press Ctrl+K Ctrl+F (Cmd+K Cmd+F).
  4. To format on save, add "[sql]": {"editor.formatOnSave": true, "editor.defaultFormatter": "zovo.zovo-sql-formatter"} to your settings.
  5. Click the dialect in the status bar to pick another one for this file. For SQL inside a Python, JavaScript or Java string, put the cursor in the string and choose Format SQL in String.

Steps in Cursor, Windsurf or VSCodium

  1. Open the Extensions view with Ctrl+Shift+X (Cmd+Shift+X on macOS).
  2. Search for zovo.zovo-sql-formatter and click Install. Cursor, Windsurf and VSCodium install from Open VSX, where it is published as zovo/zovo-sql-formatter.
  3. If your editor has no gallery, download the .vsix from the Open VSX page and run "Extensions: Install from VSIX...".
  4. Then use it the same way as in VS Code.

What SQL Safe Formatter handles

What it does not do

In JetBrains IDEs (IntelliJ IDEA, PyCharm, WebStorm, CLion and others)

Other options

Install counts and Open VSX status were checked on 9 November 2026. Descriptions in quotes are the extensions' own.

Questions

Why does VS Code say there is no formatter for SQL files?

VS Code has syntax colors for SQL but no SQL formatter. Install one, and Format Document works.

Will it break my PostgreSQL functions?

No. $$, $tag$ and $BODY$ bodies are kept byte for byte, and every result is compared token by token with your SQL before it is applied. If a token would change, the file is left as it was.

What does it use inside?

The open source sql-formatter library (MIT) formats plain statements. The token check, the dialect detection, the procedure layout and the handling of client lines such as GO and DELIMITER are its own.

More about SQL Safe Formatter

Read the SQL Safe Formatter page for every feature and setting, or the source code on GitHub.

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.