Registry / devops / cli-sql-formatter

cli-sql-formatter

JSON →
library1.3.4jsnpmunverified

A command-line interface for sql-formatter-plus, providing SQL formatting from terminals and shell scripts. Version 1.3.4 is current with stable release cadence. Supports multiple dialects: Standard SQL, Couchbase N1QL, IBM DB2, Oracle PL/SQL. Read input via pipe, file, or stdin; output to stdout or file. Indentation, uppercase, and line break options. Differentiates by being a dedicated CLI tool, not a library, with no Node.js programmatic API.

npm install cli-sql-formatter
INSTALL
IMPORT
SIG · CLI-SQL-FORMATTER
C
cli-sql-formatter
devopsjavascriptv1.3.4
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.

CLI usage
cli-sql-formatter --help
require('cli-sql-formatter')
This package is CLI-only and has no programmatic API; do not import via require/import.
NPM global install
npm install -g cli-sql-formatter @1.3.4
npm install cli-sql-formatter (without -g)
Install globally for terminal usage; local install also works but requires npx.
Piped input
echo 'SELECT 1' | cli-sql-formatter
cli-sql-formatter 'SELECT 1' (no string argument support)
SQL must be passed via stdin pipe or -f file option, not as command argument.

Format SQL from a pipe with uppercase keywords and 2-space indentation.

echo "SELECT a, b, c FROM my_table WHERE x = 1" | cli-sql-formatter --dialect sql --indent 2 --uppercase
Debug
Known issues
breakingVersion 1.0.0 switched from sql-formatter to sql-formatter-plus; some formatting options changed.
fix
Update usage and check formatting output.
affects: >=1.0.0
deprecatedCLI flag --tabs (plural) deprecated in favor of --tab (singular) since v1.2.0
fix
Use --tab instead of --tabs
affects: >=1.2.0
Errors
Common errors & fixes
bash: cli-sql-formatter: command not found
Package not installed globally or not in PATH.
fix
Run `npm install -g cli-sql-formatter` and ensure global npm bin is in $PATH.
Error: Unknown dialect: ...
Specified dialect not supported.
fix
Use --dialect with one of: sql, n1ql, db2, pl/sql
SyntaxError: Unexpected token ...
Input SQL contains syntax errors that sql-formatter-plus cannot parse.
fix
Fix the SQL syntax or use a different tool for error-tolerant formatting.
Upgrade
Version history
1.3.4latest on npm
Audit
Dependencies
sql-formatter-plusrequiredcore formatting engine
commanderrequiredCLI argument parsing
Agent activity
4 hits · last 30 days
node
4
Resources