Registry / devops / sql-formatter-plus-jinja

sql-formatter-plus-jinja

JSON →
library1.3.8jsnpmunverified

SQL Formatter Plus Jinja (v1.3.8) is a fork of sql-formatter-plus that adds support for Jinja SQL templating syntax. It pretty-prints SQL queries with configurable indentation, uppercase keywords, and language-specific formatting for Standard SQL, N1QL, DB2, and PL/SQL. It supports named and indexed placeholder replacement for parametrized queries. The library is distributed as an ESM module via npm and can also be used directly in the browser via a script tag (global window.sqlFormatter). Compared to the original sql-formatter, this fork integrates Jinja-specific syntax highlighting, making it suitable for projects using Jinja templated SQL.

npm install sql-formatter-plus-jinja
INSTALL
IMPORT
SIG · SQL-FORMATTER-PLUS
S
sql-formatter-plus-jinja
devopsjavascriptv1.3.8
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.

default
import sqlFormatter from 'sql-formatter-plus-jinja';
const sqlFormatter = require('sql-formatter-plus-jinja');
The package is ESM-only. Using CommonJS require() will fail without a bundler that can handle ESM.
format
import { format } from 'sql-formatter-plus-jinja';
import { format } from 'sql-formatter-plus-jinja/format';
Named export 'format' is available directly from the main entry point. Avoid subpath imports.
sqlFormatter
import sqlFormatter from 'sql-formatter-plus-jinja';
import { sqlFormatter } from 'sql-formatter-plus-jinja';
Default export is the whole object. Named export 'sqlFormatter' does not exist.

Demonstrates basic formatting with Jinja language, custom indent, uppercase keywords, and indexed placeholder replacement.

import sqlFormatter from 'sql-formatter-plus-jinja'; const query = 'SELECT a, b FROM my_table WHERE c = ? AND d IN (?, ?)'; const formatted = sqlFormatter.format(query, { language: 'jinja', indent: ' ', uppercase: true, linesBetweenQueries: 2, params: [1, 2, 3] }); console.log(formatted); // Output: // SELECT // a, // b // FROM // my_table // WHERE // c = 1 // AND d IN (2, 3)
Debug
Known issues
deprecatedThe 'language' option defaults to 'jinja' but other dialects like 'sql', 'n1ql', 'db2', 'pl/sql' are available.
fix
Set language explicitly to avoid surprises, e.g., language: 'sql' for standard SQL.
affects: >=1.0.0
breakingThis package is a fork of sql-formatter-plus and may have diverged in API or behavior. Check the release notes for differences.
fix
Refer to the original sql-formatter-plus documentation for base API, but test thoroughly with this fork.
affects: >=1.0.0
gotchaThe package is ESM-only; attempts to use require() will throw an error in Node.js without a bundler.
fix
Use dynamic import() or ensure your project is configured for ESM (e.g., type: 'module' in package.json).
affects: >=1.0.0
Errors
Common errors & fixes
SyntaxError: Cannot use import statement outside a module
The library is ESM-only, but the consuming project is using CommonJS or missing 'type': 'module'.
fix
Add 'type': 'module' to your package.json, or use dynamic import() instead of static import.
Error: Cannot find module 'sql-formatter-plus-jinja'
The package is not installed or the import path is incorrect.
fix
Run 'npm install sql-formatter-plus-jinja' and ensure the import path is exact.
TypeError: sqlFormatter.format is not a function
The default import is the format function itself, not an object containing format.
fix
Use import sqlFormatter from 'sql-formatter-plus-jinja'; then call sqlFormatter.format().
Upgrade
Version history
1.3.8latest on npm
Audit
Dependencies
sql-formatter-plusoptionalThis package is a fork of sql-formatter-plus and may depend on its core formatting logic.
Agent activity
3 hits · last 30 days
node
2
Resources
sql-formatter-plus-jinja — npm install sql-formatter-plus-jinja · libregistry