node-mssql

The Node.js client for Microsoft SQL Server, wrapping Tedious (or MSNodeSQLv8) behind a unified pool, request, and transaction API.

Library
npm
v12.7.0
2,274stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
94/100Excellent
Development Activity92
Maintenance96
Community88
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
81/100Excellent
Architecture85
Code Quality82
Innovation68
Learning Curve90

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 ConnectionPool class (plus a convenience global pool via sql.connect()) that manages TDS connections using the tarn pooling library, with configurable min/max pool size and idle timeout
  • Parameterized Request objects 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
  • Transaction and PreparedStatement classes for multi-statement atomic operations and repeated parameterized execution
  • Streaming support via request.stream = true with recordset/row/rowsaffected/done events, plus request.pause()/resume() for backpressure on large result sets
  • Bulk insert support (Request.bulk()) and a Table helper 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 Transaction for 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

JavaScript
95%
MIT

AnythingLLM

Developer Tools · Automation · AI Assistants

65,696

The all-in-one AI platform for private document chat, no-code agents, and local LLMs with zero setup friction.

View details
90
Repo Health
78
Technical
64
Dependency
Built with
JavaScript95%
Updated 3 days ago
TypeScript
69%
Other

Budibase

Low Code Platforms · No Code Platforms

28,260

Build AI agents, automations, and internal apps on a single open-source platform with full self-hosting control.

View details
91
Repo Health
81
Technical
63
Dependency
Built with
TypeScript69%
Svelte26%
Updated 2 days ago
TypeScript
82%
MIT

evidence

Analytics · Data Engineering

6,911

Turn SQL queries and markdown files into polished, interactive data apps and business intelligence reports — no drag-and-drop, no GUI, just code.

View details
87
Repo Health
79
Technical
64
Dependency
Built with
TypeScript82%
Svelte18%
Updated 3 days ago
TypeScript
97%
Other

GrowthBook

Developer Tools · Analytics · Monitoring

8,299

Open source feature flags, A/B testing, and warehouse-native experimentation that queries your existing data infrastructure—no data movement required.

View details
92
Repo Health
85
Technical
63
Dependency
Built with
TypeScript97%
Updated yesterday
TypeScript
84%
Apache 2.0

ktx

Data Engineering · Analytics · AI Development

1,577

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.

View details
76
Repo Health
85
Technical
72
Dependency
Built with
TypeScript84%
Updated 4 days ago
TypeScript
99%
Apache 2.0

Mastra Code

AI Code Assistants

27,743

"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.

View details
88
Repo Health
73
Technical
65
Dependency
Built with
TypeScript99%
Updated today
TypeScript
92%
Other

n8n

Automation · No Code Platforms

203,555

Code when you need it, UI when you don't — the workflow automation platform built for technical teams who refuse to choose.

View details
95
Repo Health
87
Technical
66
Dependency
Built with
TypeScript92%
Updated today
TypeScript
94%
Apache 2.0

OneUptime

Monitoring

7,563

The complete open-source observability platform that replaces PagerDuty, Datadog, Sentry, and StatusPage with a single self-hostable system.

View details
90
Repo Health
81
Technical
65
Dependency
Built with
TypeScript94%
Updated today
TypeScript
96%
Other

superglue

AI Agents · Data Engineering · Developer Tools

2,056

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).

View details
54
Repo Health
79
Technical
71
Dependency
Built with
TypeScript96%
Updated 2 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search