Back to SQL Formatter
SQL Formatter Guide

SQL Formatter for VS Code

Connect a VS Code extension, task, command palette action, or pre-commit hook to a dialect-aware SQL formatter. Keep formatting close to the editor while reviewing the exact SQL changes before they reach your repository.

A practical VS Code formatting workflow

Use the editor for authoring and the formatter API for a deterministic save or check step. Send the active SQL dialect with the document so a PostgreSQL query is never formatted as generic SQL or a BigQuery pipe query is treated as ordinary syntax.

For review-heavy teams, format on demand or in CI rather than silently replacing a draft. The formatter returns the complete formatted_sql value, which an extension can show in a diff editor or apply only after the developer confirms the changes.

  • Map a VS Code language or workspace setting to the API dialect identifier.
  • Keep formatting options in workspace settings so a team shares line length and casing rules.
  • Show the returned SQL in a diff before writing it back to the active document.

Call the formatter from a VS Code task

A task or extension can use the same JSON Connect endpoint as the browser. The request is stateless and does not require an API key for standard use.

Example request
curl -sS -X POST "https://api.leuduan.work/sqlformat.v1.SqlFormatService/FormatSql" \
  -H "Content-Type: application/json" \
  -H "Connect-Protocol-Version: 1" \
  -d '{"dialect":"postgresql","sql":"select id,name from users where active = true"}'

Continue with the formatter

Ready to format your SQL?

Choose a dialect, format a query, and review the result with a Git-style diff.

Open SQL Formatter