node-mssql
The Node.js client for Microsoft SQL Server, wrapping Tedious (or MSNodeSQLv8) behind a unified pool, request, and transaction API.
Repository Health
Technical Analysis
mssql is the standard way Node.js applications talk to Microsoft SQL Server. It wraps the pure-JavaScript Tedious driver by default (with an optional MSNodeSQLv8 native driver for ODBC/Windows-auth scenarios) behind a single, consistent API for connection pooling, parameterized queries, stored procedures, transactions, and prepared statements.
The library is built around a global or per-instance ConnectionPool, from which Request, Transaction, and PreparedStatement objects borrow connections and release them back automatically. It supports both callback and Promise-based usage, ES6 tagged-template queries for automatic SQL-injection-safe parameterization, and event-based streaming for processing very large result sets without loading everything into memory.
Maintained under the tediousjs GitHub organization, mssql has been the de facto SQL Server driver for Node.js since 2013, with a large contributor base, frequent releases, and semantic-release-based automated publishing. It ships a small CLI (bin/mssql) for running ad-hoc queries from config files or connection strings, and exposes a diagnostics channel for APM/tracing integrations.
What You Get
- A
ConnectionPoolclass (plus a convenience global pool viasql.connect()) that manages TDS connections using thetarnpooling library, with configurable min/max pool size and idle timeout - Parameterized
Requestobjects supporting.input()/.output()bindings, stored procedure execution, and ES6 tagged-template queries (sql.query`select * from t where id = $\{id\}`) that are automatically sanitized against SQL injection TransactionandPreparedStatementclasses for multi-statement atomic operations and repeated parameterized execution- Streaming support via
request.stream = truewithrecordset/row/rowsaffected/doneevents, plusrequest.pause()/resume()for backpressure on large result sets - Bulk insert support (
Request.bulk()) and aTablehelper for building table-valued parameters - A small CLI (
bin/mssql) for running queries directly from a connection string or JSON config file, and a diagnostics channel (node:diagnostics_channel) for tracing integrations
Common Use Cases
- Connecting a Node.js/Express/NestJS backend to an existing SQL Server or Azure SQL database
- Running parameterized queries and stored procedures safely without hand-rolling SQL-injection defenses
- Wrapping multi-step writes (e.g. order + line items) in a
Transactionfor atomicity - Streaming very large report/export queries row-by-row instead of buffering the full result set in memory
- Bulk-loading CSV/ETL data into SQL Server tables via
Request.bulk()
Under The Hood
Architecture
mssql is organized as a thin, driver-agnostic base layer (lib/base/connection-pool.js, request.js, transaction.js, prepared-statement.js) that each concrete driver extends: lib/tedious/ (the default, pure-JS TDS implementation used by index.js) and lib/msnodesqlv8/ (the native ODBC-backed alternative, entered via a separate mssql/msnodesqlv8 subpath). The base ConnectionPool extends Node’s EventEmitter and delegates actual pooling to the external tarn library, while parsing config from either an object or an ADO-style connection string via @tediousjs/connection-string. A global-connection.js module offers a singleton pool so callers can use sql.connect()/sql.query without managing a pool instance themselves. Swapping the underlying driver (e.g. moving from Tedious to MSNodeSQLv8) means extending the same base classes, which keeps the public Request/Transaction/PreparedStatement API stable across both.
Tech Stack
The package is plain CommonJS JavaScript (with a small amount of TypeScript/TSQL in the test fixtures) targeting Node >=18.19, with runtime dependencies on tedious (the TDS protocol driver), tarn (connection pooling), @tediousjs/connection-string (ADO connection-string parsing), commander (the bundled CLI), and debug (namespaced debug logging under mssql:*). Releases are fully automated via semantic-release, commitlint, and GitHub Actions (nodejs.yml), publishing to npm on conventional-commit-driven version bumps.
Code Quality
Testing is split by driver into test/tedious, test/msnodesqlv8, and test/common (unit tests, CLI tests, template-string tests), run with Mocha and linted with standard (zero-config ESLint preset) as part of npm test. Error handling is centralized through a small hierarchy of typed errors (MSSQLError, ConnectionError, RequestError, TransactionError, PreparedStatementError) that wrap driver-level errors while preserving the original error and stack trace. Commit messages are enforced via commitlint/@commitlint/config-conventional, and the CI workflow runs lint plus the unit suite on every push.
What Makes It Unique Unlike most single-driver database clients, mssql cleanly abstracts two structurally different SQL Server connection strategies (pure-JS TDS via Tedious, and native ODBC via MSNodeSQLv8) behind one identical request/transaction/pooling API, letting consumers switch drivers for platform or authentication reasons (e.g. Windows Integrated Auth) without rewriting query code. Its diagnostics-channel instrumentation and dedicated CLI are also less common additions for a database driver at this level of the stack.
Used by 11 apps in this directory
AnythingLLM
Developer Tools · Automation · AI Assistants
The all-in-one AI platform for private document chat, no-code agents, and local LLMs with zero setup friction.
Budibase
Low Code Platforms · No Code Platforms
Build AI agents, automations, and internal apps on a single open-source platform with full self-hosting control.
evidence
Analytics · Data Engineering
Turn SQL queries and markdown files into polished, interactive data apps and business intelligence reports — no drag-and-drop, no GUI, just code.
GrowthBook
Developer Tools · Analytics · Monitoring
Open source feature flags, A/B testing, and warehouse-native experimentation that queries your existing data infrastructure—no data movement required.
ktx
Data Engineering · Analytics · AI Development
ktx builds a self-improving context layer over your data warehouse so AI agents like Claude Code and Codex query it with approved metric definitions instead of reinventing SQL logic from scratch.
Mastra Code
AI Code Assistants
"A coding agent that never compacts" — a terminal-based AI coding agent built on the Mastra framework, with Observational Memory instead of context compaction, multi-model support, and OAuth login for Claude Max or ChatGPT Plus.
n8n
Automation · No Code Platforms
Code when you need it, UI when you don't — the workflow automation platform built for technical teams who refuse to choose.
OneUptime
Monitoring
The complete open-source observability platform that replaces PagerDuty, Datadog, Sentry, and StatusPage with a single self-hostable system.
superglue
AI Agents · Data Engineering · Developer Tools
superglue is an AI-agent-driven integration engine that turns plain-English descriptions of enterprise systems into production-grade API tools, ERP/CRM connectors, and data pipelines — self-hosted or cloud, Y Combinator-backed (W25).