Registry / devops / prettier-plugin-tsql

prettier-plugin-tsql

JSON →
library0.6.4jsnpmunverified

Prettier plugin for formatting T-SQL (Microsoft SQL Server) using Microsoft's official ScriptDom parser (TSql180Parser), supporting syntax up to SQL Server 2025. Version 0.6.4 is beta (breaking changes possible before 1.0). Requires .NET 8+ runtime and Node >=20. Ships TypeScript types. Differentiates from other SQL formatters by using the official parser, preserving comments and batch separators, and covering a broad range of T-SQL features including DML, CTEs, window functions, pivot, temporal tables, JSON functions, and full-text predicates. Integrates with Prettier's editor extensions.

npm install prettier-plugin-tsql
INSTALL
IMPORT
SIG · PRETTIER-PLUGIN-TS
P
prettier-plugin-tsql
devopsjavascriptv0.6.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (plugin registration)
// In .prettierrc or prettier config: { "plugins": ["prettier-plugin-tsql"] }
// No import needed; plugin is auto-discovered by Prettier
No explicit import required for Prettier plugins. Just install and add to plugins array in config.
Plugin options in config
// .prettierrc { "plugins": ["prettier-plugin-tsql"], "language": "tsql", "keywordCase": "upper", "density": "compact" }
Options are set in Prettier config, not passed programmatically to the plugin.
TypeScript usage (type imports)
import type { Options } from 'prettier-plugin-tsql';
Plugin ships TypeScript types. Can import type definitions for custom config validation.

Installation, configuration, and basic formatting of a T-SQL file using Prettier with the plugin. Shows system requirement (dotnet) and common config options.

// Install the plugin and Prettier npm install --save-dev prettier prettier-plugin-tsql // Ensure .NET 8+ runtime is installed: https://dotnet.microsoft.com/download/dotnet/8.0 // Create a .prettierrc file: // .prettierrc { "plugins": ["prettier-plugin-tsql"], "language": "tsql", "keywordCase": "upper", "density": "compact", "commaStyle": "trailing" } // Format a .sql file: npx prettier --write example.sql // Example T-SQL input (example.sql): // select * from [dbo].[users] where id = 1 // Formatted output: // SELECT * // FROM [dbo].[users] // WHERE id = 1
Debug
Known issues
deprecatedPlugin is in beta (v0.6.4). Breaking changes possible before v1.0. Not all T-SQL statements are supported; unsupported statements fall back to original text.
fix
Check documentation for supported statements and pending implementation list. Expect to manually review output.
affects: <=0.6.4
gotchaRequires .NET 8+ Runtime. If dotnet is not installed, the plugin fails with an error about missing .NET runtime.
fix
Install .NET 8+ Runtime from https://dotnet.microsoft.com/download/dotnet/8.0. SDK is not required.
affects: >=0.1.0
breakingNode.js >=20.0.0 required. Older Node versions (e.g., 18.x, 16.x) will cause installation failure or runtime errors.
fix
Upgrade Node.js to version 20.x or later.
affects: >=0.6.0
deprecatedPlugin options like `keywordCase`, `density`, `commaStyle` may change before stable release. No breaking changes yet but subject to change.
fix
Pin to exact version. Watch for updates before upgrading.
affects: <=0.6.4
gotchaUnsupported statements (e.g., some DDL, certain built-in procedures) are echoed verbatim without formatting. This can lead to partially formatted files that may not be valid T-SQL.
fix
Review output for unformatted sections. Report issues to plugin repository.
affects: <=0.6.4
Errors
Common errors & fixes
Error: .NET SDK or Runtime is not installed. Please install .NET 8+ Runtime.
Missing .NET 8+ runtime on the system.
fix
Download and install .NET 8+ Runtime from https://dotnet.microsoft.com/download/dotnet/8.0
Cannot find module 'prettier-plugin-tsql'
Plugin not installed or not added to Prettier's plugins list.
fix
Run `npm install --save-dev prettier-plugin-tsql`. Add `"plugins": ["prettier-plugin-tsql"]` to your Prettier config.
Error [ERR_REQUIRE_ESM]: require() of ES Module from CJS not supported.
Attempting to use CommonJS require() with an ES module. Prettier >=3.0.0 and this plugin are ESM-only.
fix
Use import syntax or dynamic import. Ensure your project is configured as ESM (e.g., `"type": "module"` in package.json).
Upgrade
Version history
0.6.4latest on npm
Audit
Dependencies
prettierrequiredpeer dependency - plugin requires Prettier >=3.0.0
.NET 8+ Runtimerequiredrequired to run the ScriptDom parser (not an npm dep but a system requirement)
Agent activity
2 hits · last 30 days
node
2
Resources
prettier-plugin-tsql — npm install prettier-plugin-tsql · libregistry