sql-template

JSON →
library 1.3.2 ·javascript
verified Jun 5, 2026

sql-template is a JavaScript library that uses ES6 tagged template literals to build SQL queries with parameterized placeholders, compatible with the pg (node-postgres) library. Version 1.3.2 is the latest stable release. It provides a simple, extensible tag-based system for constructing SQL strings and prepared statements automatically, escaping values to prevent SQL injection. Key features include custom transformers ($where$, $set$, $in$, etc.) for common SQL clauses, and static methods like SQL.insert, SQL.update, SQL.select for programmatic query building. Compared to other query builders, it emphasizes simplicity and direct mapping to SQL syntax while leveraging ES6 template strings for readability. The package is well-tested with 100% code coverage and is designed to be a drop-in replacement for raw SQL string formatting.