sql-builder.js v2.1.0 is a lightweight, zero-dependency SQL query builder for JavaScript and TypeScript with built-in SQL injection protection via parameterized queries and identifier validation. It supports ESM and CJS, provides a fluent chainable API for SELECT, INSERT, UPDATE, DELETE, and UPSERT, and includes advanced features like raw expressions, joins, and pagination. Compared to alternatives like knex.js, it is significantly smaller and simpler, with no external dependencies, but lacks database dialect-specific features and migration tooling. The package is released under the Anti 996 license, requires Node >=14, and follows an active release cadence.
npm install sql-builder.jsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Create SQLBuilder instance, build a SELECT query with parameterized where clause, and demonstrate INSERT query.
Only use `raw()` with trusted inputs or heavily sanitized values. Prefer parameterized queries over raw expressions whenever possible.
Use explicit aliases with AS keyword: 'users AS u'. For column-qualified names, use dot notation only when the alias is expected (e.g., 'u.id').
Create a new SQLBuilder instance for each query, or clone the builder if supported (check docs).
Use `raw('1')` for literal numbers, but be aware of injection risks.Always use `raw()` from the package for raw expressions, not plain strings.
Use: import { SQLBuilder } from 'sql-builder.js'Run: npm install sql-builder.js --save
Use CommonJS: const { SQLBuilder } = require('sql-builder.js')Use the `raw()` function to bypass validation or adjust the column name to match allowed pattern.
No dependency data recorded yet.