A minimal SQL string escaping library to prevent SQL injection attacks. Current stable version is 1.2.2, with infrequent releases and no breaking changes expected. It provides a single function to escape single quotes and optionally backslashes, supporting both standard SQL (backslash not supported) and engines that do support backslash escapes. Ships TypeScript types. Key differentiator: simplicity and zero dependencies.
npm install escape-sql-stringNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic use of escapeString with default options and with backslash support enabled.
Set `{ backslashSupported: true }` if your SQL engine supports backslash escapes, or manually escape backslashes.Always pass a string to escapeString.
Consider using `sqlstring` or `mysql2`'s escaping functions for broader support.
Use ES module import: `import escapeString from 'escape-sql-string'`.
Set `"type": "module"` in package.json or use a bundler that supports ESM.
Use `import escapeString from 'escape-sql-string'` instead of `import { escapeString } from 'escape-sql-string'`.No dependency data recorded yet.