Prettier SQL
Welcome to Prettier SQL, a Visual Studio Code extension that formats SQL code. This extension helps you maintain clean and consistent SQL code formatting, making it easier to read and understand.
Features
SQL dialect support
Prettier SQL supports various SQL dialects, including:
auto,
sql,
bigquery,
clickhouse,
db2,
db2i,
duckdb,
hive,
mariadb,
mysql,
tidb,
n1ql,
plsql,
oracle,
postgresql,
redshift,
singlestoredb,
snowflake,
spark,
sqlite,
mssql,
mssqlserver,
transactsql,
trino
Development setup
Install:
git clone https://github.com/olton/prettier-sql.git
cd prettier-sql
Build extension sources:
npm run build
Open this project in VS Code and press F5 to start the Extension Development Host.
Installation
Usage
- Open a
.sql file.
- Run
Format Document or command PrettierSQL: Format.
- Optionally select part of SQL and run
Format Selection for range formatting.
- Configure behavior in VS Code settings with these options:
prettiersql.enable
prettiersql.printWidth
prettiersql.tabWidth
prettiersql.useTabs
prettiersql.singleQuote
prettiersql.operatorNewLine
prettiersql.logicalOperatorNewLine (before | after)
prettiersql.keywordsCase (none | upper | lower)
prettiersql.functionCase (none | upper | lower)
prettiersql.linesBeforeQueries
prettiersql.endOfLine (lf | crlf | cr | auto)
prettiersql.dialect
The extension uses sql-formatter under the hood and applies the options above during formatting.
When prettiersql.dialect is auto, the formatter infers a dialect from current editor language id.
Commands
PrettierSQL: Format - formats current SQL document.
PrettierSQL: Set As Default Formatter - sets PrettierSQL as default formatter for SQL in user or workspace settings.
PrettierSQL: Show Output - opens extension output channel.
PrettierSQL: Refresh - reloads VS Code window.
Contributing
Contributions are welcome. Feel free to submit a pull request or open an issue.
Support
If you like this project, please consider supporting it by:
- Star this repository on GitHub
- Sponsor this project on GitHub Sponsors
- PayPal to
serhii@pimenov.com.ua.
- Patreon
- Buy me a coffee
Copyright (c) 2026 by Serhii Pimenov. All Rights Reserved.
| |