Registry / database / sql-formatter-with-sql-server

sql-formatter-with-sql-server

JSON →
library1.0.2jsnpmunverified

A JavaScript library for pretty-printing SQL queries, forked to add SQL Server dialect support. Current stable version is 1.0.2. Low release cadence (last update 2020). Key differentiators: supports Standard SQL, N1QL, DB2, Oracle PL/SQL, and now SQL Server; parameter placeholder replacement; works in Node.js and browsers. Alternatives like prettier-plugin-sql have broader community but this fork fills the gap for T-SQL formatting.

npm install sql-formatter-with-sql-server
INSTALL
IMPORT
SIG · SQL-FORMATTER-WITH
S
sql-formatter-with-sql-server
databasejavascriptv1.0.2
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.

sqlFormatter
✓ import sqlFormatter from 'sql-formatter-with-sql-server'
✗ const sqlFormatter = require('sql-formatter-with-sql-server')
Default ESM export. CommonJS require() may work in Node but is not officially supported.
format (default)
✓ import sqlFormatter from 'sql-formatter-with-sql-server'; sqlFormatter.format(...)
✗ import { format } from 'sql-formatter-with-sql-server'
The default export is an object with a format method, not a named export.
sqlFormatter (script tag)
✓ <script src='dist/sql-formatter.min.js'></script>; window.sqlFormatter.format(...)
✗ import sqlFormatter from 'sql-formatter-with-sql-server'
When used via script tag, the library is exposed as window.sqlFormatter.

Demonstrates basic SQL formatting with custom indent and a multi-line query using the default export.

import sqlFormatter from 'sql-formatter-with-sql-server'; const formatted = sqlFormatter.format("SELECT a, b, c FROM tbl WHERE a = 1 AND b = 2", { language: 'sql', indent: ' ' }); console.log(formatted); // Output: // SELECT // a, // b, // c // FROM // tbl // WHERE // a = 1 // AND b = 2
Debug
Known issues
gotchaSQL Server dialect may not handle all T-SQL syntax (e.g., GO, DECLARE). Test extensively.
fix
Use underyling 'sql' dialect as fallback or open an issue on GitHub.
affects: >=1.0.0
deprecatedThe default language option might become deprecated in future versions as more dialects are added.
fix
Always specify language explicitly: { language: 'sql' }
affects: >=1.0.0
gotchaCommonJS require() may not work if the package is used in a strict ESM environment (e.g., Node with "type": "module").
fix
Use dynamic import or switch to ESM syntax: import sqlFormatter from 'sql-formatter-with-sql-server'
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'sql-formatter-with-sql-server'
Package not installed or misspelled (note the 'sql-formatter-with-sql-server' name).
fix
Run 'npm install sql-formatter-with-sql-server' and require/import with exact name.
TypeError: sqlFormatter.format is not a function
Incorrect import: default export is an object, not a function.
fix
Use 'import sqlFormatter from ...' then call sqlFormatter.format(...)
Uncaught ReferenceError: sqlFormatter is not defined
Using script tag without loading the file, or global variable name mismatch.
fix
Ensure the dist file is loaded before use. The global is 'sqlFormatter', not 'SqlFormatter'.
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
14 hits · last 30 days
node
12
OpenAI (training)
1
Resources
sql-formatter-with-sql-server — npm install sql-formatter-with-sql-server · libregistry