Prettier SQL v5.1.1 is a JavaScript library for pretty-printing SQL queries. It supports 12 dialects including MySQL, PostgreSQL, BigQuery, and Spark. It started as a port of a PHP library but has diverged considerably. Released regularly via npm, it offers both programmatic and CLI usage. Key differentiators: extensive dialect support, uppercase/lowercase control, placeholder replacement, and zero runtime dependencies. Types are included.
npm install prettier-sqlNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Formats a PostgreSQL query with uppercase keywords, two-space indentation, and one line between queries.
Upgrade Node to >=14 and change import from default to named.
Replace indent_width: 4 with indent: ' '
Wrap numeric placeholders in quotes: params: { foo: "'42'" }Use lowercase dialect names: sql, mysql, postgresql, etc.
Upgrade to 5.1.0+ for improved handling of DISTINCT ON.
Use --config config.json (file path) not --config '{ "key": "value" }'Use import { format } from 'prettier-sql'Use valid lowercase dialect: sql, mysql, postgresql, etc.
Run npm install prettier-sql and ensure import path matches package name.
No dependency data recorded yet.