sql-json-generator (v0.15.1) is a Node.js module that generates SQL queries (SELECT, INSERT, UPDATE, DELETE) from JSON objects, loosely based on MongoDB query syntax. It supports MySQL features like backtick escaping, aggregate functions, joins, subqueries via $raw, and SqlCalcFoundRows. The library is designed to simplify building reusable JSON query definitions for REST APIs with MySQL backends. It is not ESM-native and relies on CommonJS. Updates are infrequent; the last release was in 2021. Compared to alternatives like knex.js or sequelize, it is more lightweight but lacks ORM features and broader database support.
npm install sql-json-generatorNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic SELECT query generation with fields, WHERE condition, ordering, and limit.
Use $from object with sqlCalcFoundRows property.
Use explicit $field objects with $as for aliasing.
Use $and/$or explicit arrays to control logic grouping.
Use Node.js 8 or later.
Use CommonJS require: const SQLGenerator = require('sql-json-generator');Instantiate first: const sqlGenerator = new SQLGenerator();
Ensure $from is a string or object within queryData.