Skip to content
| Marketplace
Sign in
Visual Studio Code>Formatters>SQLFluff FormatterNew to Visual Studio Code? Get it now.
SQLFluff Formatter

SQLFluff Formatter

oboki

|
457 installs
| (0) | Free
Format SQL files using a local sqlfluff executable
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

SQLFluff Formatter

Format your SQL files in VS Code using sqlfluff.

This extension runs sqlfluff fix from VS Code and applies the formatted result back to your editor.

Features

  • Format selected SQL or the entire file
  • Uses your local sqlfluff installation and config
  • Works with any dialect supported by sqlfluff
  • Adds --dialect ansi automatically only when no dialect is provided in args or .sqlfluff
  • Resolves runtime in this order: sqlfluff.path → sqlfluff from PATH → python -m sqlfluff

How It Works

  • If you select text, only the selection is formatted.
  • If you do not select text, the entire document is formatted.
  • Line endings (LF/CRLF) are preserved.
  • Temporary files created during formatting are removed automatically.

Getting Started

  1. Install this extension from the VS Code Marketplace.
  2. Open a SQL file and run the Format SQL with SQLFluff command (Shift+Alt+S).
    • If sqlfluff.path is set and not executable, the extension returns an error and does not try auto-install.
  • If sqlfluff.path is not set and sqlfluff is not found in PATH, the extension can attempt to install sqlfluff automatically when Python is available.
  • During auto-install, the extension detects Python scripts directories and patches PATH only for extension processes (it does not modify your system shell profile).
  • If CLI exposure still fails after install, the extension falls back to python -m sqlfluff.
  • If Python is not available, install Python and/or sqlfluff manually:
    pip install --upgrade sqlfluff
    # or a specific version
    pip install "sqlfluff>=3.0.0"
    

Usage

  • Command Palette: Format SQL with SQLFluff
  • Keyboard shortcut:
    • Windows/Linux: Shift+Alt+S
    • macOS: Shift+Ctrl+S

If formatting fails, open the SQLFluff output channel to see execution logs and error details.

Configuration

  • The extension uses your workspace or user .sqlfluff config if present.
  • You can set the path to sqlfluff and extra arguments in VS Code settings (sqlfluff.path, sqlfluff.args).
  • Auto-install uses python -m pip install sqlfluff (without --user).
  • If a workspace virtual environment is found (.venv, venv, env), that Python interpreter is preferred for auto-install.

Example Settings

{
  "sqlfluff.path": "",
  "sqlfluff.args": ["--dialect", "postgres"]
}

For more details, see the sqlfluff documentation.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft