FREEDOM251

Freedom251 › SQL Linters and Formatters

prettier-plugin-sql-cst

Free plan Web

Visit prettier-plugin-sql-cst Alternatives

prettier-plugin-sql-cst's own site

What prettier-plugin-sql-cst is

prettier-plugin-sql-cst is a free Prettier plugin that formats SQL using sql-parser-cst and Prettier’s formatting algorithm. It adjusts layout to expression length, moving longer clauses and their contents onto separate lines when needed. Its stated approach favors a consistent style, formatting embedded languages, and preserving syntax when parsing is uncertain. SQLite and BigQuery have full support; PostgreSQL, PL/pgSQL, MySQL, and MariaDB are experimental because parser syntax support is incomplete. The README describes using special comments to bracket SQL sections that should not be parsed. Configuration includes Prettier’s printWidth, tabWidth, and useTabs options, plus SQL-specific casing settings for keywords, literals, types, identifiers, and functions. Bound SQL parameter placeholders are rejected by default, though sqlParamTypes can be set to recognize specified forms. Installation instructions cover npm, pnpm, and Yarn, and the plugin can be used with Prettier’s VSCode extension; SQL document selectors may be needed. It also supports formatting SQL strings inside JavaScript when used with prettier-plugin-embed. The project is GPL-3.0 licensed and links to a live formatting playground.

Who it suits

This plugin suits developers who use Prettier to format SQL, particularly in SQLite or BigQuery. Teams using the experimental dialects should account for incomplete parser support.

What it does well

  • Full support for SQLite and BigQuery
  • Adjusts SQL layout to expression length
  • Works with Prettier’s VSCode extension
  • Offers casing options for SQL elements
  • Links to a live SQL formatting playground

What to know first

  • Four listed dialects have experimental support
  • Bound SQL placeholders are rejected by default
  • Formatting style details remain subject to change
  • Identifier and function case options are experimental

Limits

SQLite and BigQuery are fully supported, while PostgreSQL, PL/pgSQL, MySQL, and MariaDB have incomplete parser support. Bound parameter placeholders are rejected unless sqlParamTypes is configured, and unsupported sections must be bracketed with special comments.

Getting started

  1. Install the plugin and Prettier with npm, pnpm, or Yarn
  2. Configure the plugin in your Prettier setup
  3. Use it through Prettier or the VSCode extension
  4. Set the VSCode extension as the default formatter and add SQL document selectors if needed
  5. Configure printWidth, tabWidth, useTabs, casing, or sqlParamTypes options
  6. Add prettier-plugin-embed when formatting SQL strings inside JavaScript

Verdict

prettier-plugin-sql-cst offers SQL formatting within Prettier, with full support for SQLite and BigQuery. Check parser limitations before relying on it for PostgreSQL, PL/pgSQL, MySQL, or MariaDB.

Questions

Is prettier-plugin-sql-cst free?

Yes. It has a free plan and the repository identifies it as GPL-3.0 licensed.

Which SQL dialects are supported?

SQLite and BigQuery have full support. PostgreSQL, PL/pgSQL, MySQL, and MariaDB are experimental.

Can it format SQL in VSCode?

Yes. It works with Prettier’s VSCode extension and can be configured as the default formatter.

How do I install it?

The README provides npm, pnpm, and Yarn commands that install the plugin with Prettier as development dependencies.

What happens with bound SQL parameters?

Bound placeholders are rejected by default; sqlParamTypes can be set for specified placeholder forms.

Can it format SQL embedded in JavaScript?

The README recommends using prettier-plugin-embed together with this plugin for SQL strings inside JavaScript.

Facts from prettier-plugin-sql-cst's own pages

Bound parameters
Bound SQL parameter placeholders are rejected by default, and users can configure sqlParamTypes to recognize specified placeholder forms. · github.com, 8 Oct 2026
Configuration
It supports Prettier’s printWidth, tabWidth, and useTabs options, plus SQL-specific options for keyword, literal, type, identifier, and function casing. · github.com, 8 Oct 2026
Dialect limits
The experimental dialects are limited by incomplete parser syntax support, and the README says unsupported SQL sections can be bracketed with special comments to disable parsing. · github.com, 8 Oct 2026
Editor integration
The plugin can be used with Prettier’s VSCode extension, configured as the default formatter, with document selectors potentially needed for SQL files. · github.com, 8 Oct 2026
Embedded SQL
The README recommends using prettier-plugin-embed together with this plugin to format SQL strings inside JavaScript files. · github.com, 8 Oct 2026
Experimental dialects
PostgreSQL, PL/pgSQL, MySQL, and MariaDB are listed as experimental, and the README says parser syntax support is incomplete for these dialects. · github.com, 8 Oct 2026
Formatting
It adapts SQL layout to expression length, placing longer clauses and their contents on separate lines as needed. · github.com, 8 Oct 2026
Installation
The README gives npm, pnpm, and yarn commands for installing the plugin with Prettier as a development dependency. · github.com, 8 Oct 2026
License
The repository identifies the project as GPL-3.0 licensed. · github.com, 8 Oct 2026
Limitations
The README says SQL formatting style details remain subject to change and describes identifier and function case options as experimental and not thoroughly tested. · github.com, 8 Oct 2026
Live demo
The project README links to a live SQL formatting playground. · github.com, 8 Oct 2026
Maintainer
The maintainer profile identifies Rene Saarsoo and lists Tartu, Estonia as his location. · github.com, 8 Oct 2026
Purpose
It is a Prettier plugin for formatting SQL that uses sql-parser-cst and Prettier’s formatting algorithm. · github.com, 8 Oct 2026
Style
Its stated formatting philosophy is to use one style, avoid configuration options, format embedded languages, and preserve syntax when uncertain. · github.com, 8 Oct 2026
Supported dialects
SQLite and BigQuery have full support; PostgreSQL, PL/pgSQL, MySQL, and MariaDB are experimental. · github.com, 8 Oct 2026

Where prettier-plugin-sql-cst stands on Freedom251

Look at these too