SQL Formatter is a JavaScript library for pretty-printing SQL queries, supporting Standard SQL, Couchbase N1QL, IBM DB2, and Oracle PL/SQL dialects. Current stable version is 2.3.2, with maintenance releases over years. Key differentiator: lightweight, no dependencies, supports placeholder replacement (named and indexed). Lacks TypeScript support in v2 but widely used for formatting SQL in Node.js and browser. Alternatives exist (e.g., prettier-plugin-sql) but sql-formatter is simpler and more focused.
npm install sql-formatNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates formatting SQL with parameter substitution for named placeholders.
Always pass a `params` object or array when using placeholders to avoid unformatted tokens.
Explicitly set `indent` option to your preference (e.g., '\t' for tabs).
Verify formatted output for non-supported dialects; consider testing or using a more comprehensive formatter.
Use import statement with module bundler like webpack or rollup.
Create a declaration file or use @ts-ignore.
Use correct import: import sqlFormatter from 'sql-formatter' (if using ESM) or const sqlFormatter = require('sql-formatter').default (if mixing CJS/ESM).Switch to a more appropriate dialect (e.g., 'n1ql' for Couchbase) or use a more comprehensive formatter.
Use one of: 'sql', 'n1ql', 'db2', 'pl/sql'. For MySQL, try the default 'sql' dialect.
Add params: { foo: 'value' } for named placeholders, or params: ['value'] for indexed.No dependency data recorded yet.