Registry / devops / sql-prettier

sql-prettier

JSON →
library0.2.12jsnpmunverified

A SQL formatter that whitespaces and indents SQL queries for improved readability. Current stable version 0.2.12, last updated in 2018. Forked from sql-formatter, it supports SQL, N1QL, and a subset of standard SQL. Differentiator: simple, no dependencies, but limited to whitespace formatting without comprehensive keyword case or dialect-specific logic. Release cadence is low, mostly maintenance.

npm install sql-prettier
INSTALL
IMPORT
SIG · SQL-PRETTIER
S
sql-prettier
devopsjavascriptv0.2.12
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 sqlPrettier from 'sql-prettier'
const sqlPrettier = require('sql-prettier').default
Default export with ESM; CommonJS users can use require('sql-prettier').default
format
import { format } from 'sql-prettier'
import sqlPrettier from 'sql-prettier'; sqlPrettier.format
Named export 'format' is not directly available; use default export and call .format
SqlFormatter
import SqlFormatter from 'sql-prettier'
const SqlFormatter = require('sql-prettier')
No named exports; default export is a function, not a class

Shows basic usage: importing and formatting a simple SQL query with SELECT, FROM, WHERE, ORDER BY.

import sqlPrettier from 'sql-prettier'; const formatted = sqlPrettier.format('SELECT id, name FROM users WHERE age > 18 ORDER BY name'); console.log(formatted); // Output: // SELECT id, // name // FROM users // WHERE age > 18 // ORDER BY name
Debug
Known issues
breakingThe library does not preserve original case; always uppercases keywords.
fix
If case preservation is needed, consider another formatter (e.g., sql-formatter).
affects: *
breakingDoes not support many SQL dialects; focused on standard SQL and N1QL.
fix
Test with your SQL dialect; use dialect-specific formatters like sql-formatter for MySQL, PostgreSQL.
affects: *
gotchaThe default export is a function, not an object with .format; direct import as default then call.
fix
Use: import sqlPrettier from 'sql-prettier'; then sqlPrettier.format(...)
affects: 0.x
Errors
Common errors & fixes
TypeError: sql_prettier_1.default is not a function
Using CommonJS require and treating it as a function directly without .default.
fix
const sqlPrettier = require('sql-prettier').default;
Module not found: Can't resolve 'sql-prettier'
Package not installed or import path incorrect (e.g. missing from package.json).
fix
npm install sql-prettier
Upgrade
Version history
0.2.12latest on npm
Audit
Dependencies

No dependency data recorded yet.

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