Gathering detailed insights and metrics for cl-sql-formatter
Gathering detailed insights and metrics for cl-sql-formatter
Gathering detailed insights and metrics for cl-sql-formatter
Gathering detailed insights and metrics for cl-sql-formatter
A whitespace formatter for different query languages
npm install cl-sql-formatter
Typescript
Module System
Node Version
NPM Version
TypeScript (95.65%)
Nearley (1.66%)
JavaScript (1.4%)
HTML (1.09%)
CSS (0.2%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
2,612 Stars
3,033 Commits
427 Forks
26 Watchers
10 Branches
56 Contributors
Updated on Jul 15, 2025
Latest Version
4.0.11
Package Id
cl-sql-formatter@4.0.11
Unpacked Size
809.58 kB
Size
171.08 kB
File Count
49
NPM Version
6.14.15
Node Version
14.18.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
20
SQL Formatter is a JavaScript library for pretty-printing SQL queries. It started as a port of a PHP Library, but has since considerably diverged.
SQL formatter supports the following dialects:
It does not support:
;
.Get the latest version from NPM:
1npm install sql-formatter
1import { format } from 'sql-formatter'; 2 3console.log(format('SELECT * FROM tbl'));
This will output:
1SELECT
2 *
3FROM
4 tbl
You can also pass in configuration options:
1format('SELECT * FROM tbl', { 2 language: 'spark', // Defaults to "sql" (see the above list of supported dialects) 3 indent: ' ', // Defaults to two spaces 4 uppercase: bool, // Defaults to false (not safe to use when SQL dialect has case-sensitive identifiers) 5 linesBetweenQueries: 2, // Defaults to 1 6});
1// Named placeholders 2format("SELECT * FROM tbl WHERE foo = @foo", { 3 params: {foo: "'bar'"} 4})); 5 6// Indexed placeholders 7format("SELECT * FROM tbl WHERE foo = ?", { 8 params: ["'bar'"] 9}));
Both result in:
SELECT
*
FROM
tbl
WHERE
foo = 'bar'
The CLI tool will be installed under sql-formatter
and may be invoked via npx sql-formatter
:
1sql-formatter -h
usage: sql-formatter [-h] [-o OUTPUT] [-l {db2,mariadb,mysql,n1ql,plsql,postgresql,redshift,spark,sql,tsql}]
[-i N | -t] [-u] [--lines-between-queries N] [--version] [FILE]
SQL Formatter
positional arguments:
FILE Input SQL file (defaults to stdin)
optional arguments:
-h, --help show this help message and exit
-o OUTPUT, --output OUTPUT
File to write SQL output (defaults to stdout)
-l {db2,mariadb,mysql,n1ql,plsql,postgresql,redshift,spark,sql,tsql},
--language {db2,mariadb,mysql,n1ql,plsql,postgresql,redshift,spark,sql,tsql}
SQL Formatter dialect (defaults to basic sql)
-i N, --indent N Number of spaces to indent query blocks (defaults to 2)
-t, --tab-indent Indent query blocks with tabs instead of spaces
-u, --uppercase Capitalize language keywords
--lines-between-queries N
How many newlines to insert between queries (separated by ";")
--version show program's version number and exit
By default, the tool takes queries from stdin and processes them to stdout but
one can also name an input file name or use the --output
option.
1echo 'select * from tbl where id = 3' | sql-formatter -u
1SELECT
2 *
3FROM
4 tbl
5WHERE
6 id = 3
If you don't use a module bundler, clone the repository, run npm install
and grab a file from /dist
directory to use inside a <script>
tag.
This makes SQL Formatter available as a global variable window.sqlFormatter
.
Make sure to run all checks:
1npm run check
...and you're ready to poke us with a pull request.
versions:
xx
变成xx
,a-b变成a - b问题, @#等][]No vulnerabilities found.
Reason
30 commit(s) and 22 issue activity found in the last 90 days -- score normalized to 10
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 3/17 approved changesets -- score normalized to 1
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
10 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More