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.
QueryFormatter
✓ import { QueryFormatter } from 'google-sql-syntax-ts'
✗ const { QueryFormatter } = require('google-sql-syntax-ts')
ESM-only package; cannot use require(). Must use dynamic import or ESM.
GoogleSqlDefinition
✓ import { GoogleSqlDefinition } from 'google-sql-syntax-ts'
Default export of the language definition; often used alongside QueryFormatter.
googleSqlLanguageConfiguration
✓ import { googleSqlLanguageConfiguration } from 'google-sql-syntax-ts'
For Monaco Editor only. Import as a named export.
Demonstrates formatting a GoogleSQL query using QueryFormatter and GoogleSqlDefinition.
import { QueryFormatter, GoogleSqlDefinition } from 'google-sql-syntax-ts';
const queryFormatter = new QueryFormatter(new GoogleSqlDefinition());
const formattedQuery = queryFormatter.formatQuery(
"SELECT column, REGEXP_CONTAINS(column, r'a') AS column_contains_a FROM `some-table` WHERE date > 1970-01-01"
);
console.log(formattedQuery);
// Output:
// SELECT
// COLUMN,
// REGEXP_CONTAINS(COLUMN, r'a') AS column_contains_a
// FROM
// `some-table`
// WHERE
// date > 1970-01-01
Debug
Known issues
gotchaQueryFormatter converts identifiers to UPPER CASE by default (e.g., 'column' -> 'COLUMN'). This may not be desired for users expecting case preservation.fixIf you need case preservation, consider using a different SQL formatter or overriding behavior via options (if available).
affects: >=1.0.0
breakingPackage is ESM-only; Node.js versions <12 may not support ESM without experimental flags.fixUse Node.js >=12 with "type": "module" in package.json, or use dynamic import for older Node.
affects: >=1.0.0
deprecatedNo version deprecations noted; package is small and stable.
gotchaNo browser bundle provided; importing directly into browser may require bundler (Webpack, Rollup).fixUse a bundler to resolve ESM imports. Alternatively, use CDN via esm.sh.
affects: >=1.0.0
Errors
Common errors & fixes
SyntaxError: The requested module 'google-sql-syntax-ts' does not provide an export named 'QueryFormatter'
CommonJS require() used instead of ESM import.
fixReplace require() with import statement. If you must use require, use dynamic import: const { QueryFormatter } = await import('google-sql-syntax-ts'); TypeError: GoogleSqlDefinition is not a constructor
Forgot to import GoogleSqlDefinition or used wrong import pattern.
fixEnsure both imports: import { QueryFormatter, GoogleSqlDefinition } from 'google-sql-syntax-ts'; Cannot find module 'google-sql-syntax-ts'
Package not installed or missing from node_modules.
fixRun: npm install @google/google-sql-syntax-ts (note scoped package name)
Audit
Dependencies
No dependency data recorded yet.