connection-string is an advanced JavaScript library for parsing and generating URL connection strings, offering features beyond standard URL parsers. It supports a fully optional syntax for every component, multiple hosts, unification of Unix socket support with URL standards, automatic defaults configuration for missing parameters, and the ability to reconstruct a connection string from an object. The current stable version is 5.0.0, released in late 2025/early 2026. Releases are active but not on a fixed cadence, focusing on maintenance, compatibility, and feature enhancements. Key differentiators include its flexible parsing for partial or complex connection strings (e.g., with multiple hosts or specific Unix socket patterns) and its ability to apply defaults, making it highly versatile for database and service connection configurations. The library ships with TypeScript types.
npm install connection-stringVerified import paths — ran on the pinned version, not inferred.
Demonstrates parsing a complex connection string, accessing parsed properties, applying default values, and generating a connection string from an object.
Ensure your environment supports ES2020. No direct code fix is required if your code didn't rely on the removed Node.js specifics or color output features.
Upgrade your Node.js runtime to version 20 or newer. For older Node.js environments, use `connection-string` v4.x.
Upgrade to `connection-string` version 4.3.1 or newer to ensure correct handling of repeated and comma-separated parameters and URL-encoded commas (`%2C`) in query strings.
Use a bundler like Webpack or Rollup for browser applications, or ensure your environment supports ES Modules for direct import. Refer to the 'Browsers' page in the package's documentation for details.
Ensure you are using `new ConnectionString(...)` to create an instance. If using ESM, verify your import is `import { ConnectionString } from 'connection-string';` (named import).For ESM, use `import { ConnectionString } from 'connection-string';`. For CommonJS, use `const { ConnectionString } = require('connection-string');`. Ensure your `tsconfig.json` (if applicable) and `package.json` `type` field are configured correctly for your module system.No dependency data recorded yet.