Registry / devops / sql-formatter-plus

sql-formatter-plus

JSON →
library1.3.6jsnpmunverified

SQL Formatter Plus is a fork of SQL Formatter that adds bug fixes and features like keyword uppercasing and configurable line breaks between queries. Current stable version is 1.3.6. It formats SQL queries with support for Standard SQL, Couchbase N1QL, IBM DB2, and Oracle PL/SQL dialects. Differentiating features include placeholder replacement, configurable indentation, and ESM module support. It is released on npm and compatible with Node.js and browsers.

npm install sql-formatter-plus
INSTALL
IMPORT
SIG · SQL-FORMATTER-PLUS
S
sql-formatter-plus
devopsjavascriptv1.3.6
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

sqlFormatter
import sqlFormatter from 'sql-formatter-plus'
Default import is the standard way to use the library in ESM environments.
sqlFormatter
const sqlFormatter = require('sql-formatter-plus')
CommonJS require works for Node.js usage.

Demonstrates basic formatting of a SELECT query with parameter replacement.

import sqlFormatter from 'sql-formatter-plus'; const query = 'SELECT * FROM users WHERE id = ?'; const formatted = sqlFormatter.format(query, { language: 'sql', indent: ' ', uppercase: false, linesBetweenQueries: 1, params: [1] }); console.log(formatted); // Output: // SELECT // * // FROM // users // WHERE // id = 1
Debug
Known issues
gotchaThe package name is 'sql-formatter-plus', but the import path in the README shows 'sql-formatter' in one place. Ensure you use 'sql-formatter-plus' for imports.
fix
Always use the actual package name 'sql-formatter-plus' for importing.
affects: >=1.0.0
gotchaOptions like 'uppercase' and 'linesBetweenQueries' are specific to this fork and may not be present in the original sql-formatter.
fix
Check documentation for available options; these features are specific to this fork.
affects: >=1.0.0
gotchaParameter replacement with 'params' expects values to be strings with quotes included. For example, use "'bar'" instead of 'bar'.
fix
Pass parameters as properly quoted strings: params: {foo: "'bar'"} or params: ["'bar'"].
affects: >=1.0.0
gotchaThis library only supports four SQL dialects: sql, n1ql, db2, pl/sql. Other dialects may not format correctly.
fix
Ensure your SQL dialect is among the supported ones, otherwise formatting may be incorrect.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: sqlFormatter.format is not a function
Importing the module incorrectly (e.g., using named import instead of default).
fix
Use default import: import sqlFormatter from 'sql-formatter-plus'
Error: Unknown language: 'postgresql'
Specifying an unsupported dialect.
fix
Use one of: 'sql', 'n1ql', 'db2', 'pl/sql'
Unexpected token: ...
Unmatched parentheses or syntax errors in the query.
fix
Check the SQL syntax; the formatter expects valid SQL.
Upgrade
Version history
1.3.6latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
Resources
sql-formatter-plus — npm install sql-formatter-plus · libregistry