Prettier Plugin for BigQuery SQL
raw JSON → 1.0.5 verified Sat Apr 25 auth: no javascript
A prettier plugin for formatting GoogleSQL (BigQuery dialect) files. Supports pipe syntax, procedural language (BigQuery Scripting), and experimental Jinja template handling. v1.0.5 is current with a moderate release cadence. Requires prettier ^3.2.4 as a peer dependency. Ship TypeScript types. Differentiator vs other SQL formatters: specifically targets GoogleSQL, not generic or MySQL/PostgreSQL dialects. Active development, community-driven.
Common errors
error Cannot find module 'prettier-plugin-bq' ↓
cause The plugin is not installed or not resolved by prettier. Usually because prettier v2 is installed, or the plugin is not listed in .prettierrc.
fix
npm install prettier@latest prettier-plugin-bq --save-dev and add "plugins": ["prettier-plugin-bq"] to .prettierrc
error TypeError: Cannot read properties of undefined (reading 'format') ↓
cause Using require('prettier-plugin-bq') and trying to call it as a function. The plugin is not a module to import programmatically.
fix
Do not import the plugin directly; configure it via .prettierrc or CLI.
Warnings
gotcha Plugin does not work with prettier v2; requires prettier ^3.2.4. If you have prettier v2 installed, the plugin will not be loaded and no formatting will occur. ↓
fix Update prettier to v3.2.4 or later: npm install prettier@latest --save-dev
deprecated Option printPseudoColumnsInUpperCase was merged into printKeywordsInUpperCase. Using the old name may be ignored or cause errors in future versions. ↓
fix Use printKeywordsInUpperCase instead of printPseudoColumnsInUpperCase.
gotcha Jinja template support is experimental and may produce incorrect formatting or errors if Jinja statements do not contain valid SQL expressions. ↓
fix Ensure Jinja tags wrap valid SQL expressions; avoid placing statements like WHERE or JOIN entirely inside Jinja conditionals.
gotcha The plugin does not follow any famous style guides; it formats according to its own heuristics, which may differ from expectations of BigQuery style guides. ↓
fix Review formatting output and adjust options (e.g., printKeywordsInUpperCase) to match preferred style.
Install
npm install prettier-plugin-bq yarn add prettier-plugin-bq pnpm add prettier-plugin-bq Imports
- prettier-plugin-bq wrong
const plugin = require('prettier-plugin-bq')correctimport {} from 'prettier-plugin-bq' // no export, plugin auto-detected - prettier wrong
const prettier = require('prettier')correctimport prettier from 'prettier' - default (prettier instance) wrong
const prettier = require('prettier')correctimport * as prettier from 'prettier'
Quickstart
npm install --save-dev prettier prettier-plugin-bq
echo "SELECT
name,
SUM(salary) AS total_salary
FROM
employees
WHERE
department = 'Engineering'
GROUP BY
name
HAVING
total_salary > 100000
ORDER BY
total_salary DESC;" > query.sql
npx prettier --write query.sql --plugin=prettier-plugin-bq