Registry / database / pgsql-minify

pgsql-minify

JSON →
library1.0.7jsnpmunverified

A TypeScript library that minifies valid Postgres SQL by tokenizing the statement and reconstructing it with standardized case and spacing. Version 1.0.7 is the current stable release, updated as needed. Key differentiator: provides a lexer, configurable keyword sets, and comment handling, making it suitable for postgres-specific SQL formatting without full parsing.

npm install pgsql-minify
INSTALL
IMPORT
SIG · PGSQL-MINIFY
P
pgsql-minify
databasejavascriptv1.0.7
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.

minify
import { minify } from 'pgsql-minify'
const minify = require('pgsql-minify').minify
Default export not available; named export only.
lex
import { lex } from 'pgsql-minify'
const lex = require('pgsql-minify/lex')
Named export from the main package.
TokenType
import type { TokenType } from 'pgsql-minify'
import { TokenType } from 'pgsql-minify'
TokenType is a type alias, import using 'import type' for TypeScript.

Demonstrates minifying a multi-line SQL string with mixed case and tabs into a single-line, lowercase, minimal-spacing format.

import { minify } from 'pgsql-minify'; const rawSQL = 'select col1, col2,\n\tcol3\nFROM\tsome_table;'; const niceSQL = minify(rawSQL); console.log(niceSQL); // 'select col1, col2, col3 from some_table;'
Debug
Known issues
gotchaInput SQL must be syntactically valid; invalid SQL produces undefined output.
fix
Ensure SQL is valid before minifying.
affects: all
gotchaComments are removed by default; set includeComments: true to preserve them.
fix
Pass { includeComments: true } to minify or lex options.
affects: all
gotchaThe default keyword set follows PostgreSQL; custom keywords may cause formatting issues.
fix
Override keywords via PgSqlMinifyOptions.keywords if using non-standard SQL.
affects: all
Errors
Common errors & fixes
TypeError: minify is not a function
Using default import instead of named import.
fix
Use import { minify } from 'pgsql-minify'
Cannot find module 'pgsql-minify/lex' or its corresponding type declarations.
Attempting to import lex from non-existent subpath. lex is a named export from the main module.
fix
Use import { lex } from 'pgsql-minify'
TS2304: Cannot find name 'TokenType'
TokenType is exported as a type, not a value. Using it as a value at runtime will fail.
fix
Use 'import type { TokenType } from 'pgsql-minify' or use it only as a type in TypeScript.
Upgrade
Version history
1.0.7latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
pgsql-minify — npm install pgsql-minify · libregistry