libpg-query

Constructive’s WebAssembly build of the PostgreSQL parser for JavaScript. Parse SQL with the real PostgreSQL grammar without compiling a native add-on. The older @libpg-query/parser package is retired.

Part of Postgres AST Toolkit

TypeScript

Verified usage

  • Supabase Studio

    The parse-query API uses libpg-query to identify SQL operations, tables, and WHERE clauses.

    View source
  • AWS Advanced Node.js Wrapper · ESLint rule

    AWS uses libpg-query to help prevent the kind of SQL hijacking behind past driver CVEs. Before shipping the Advanced Node.js Wrapper, its ESLint rule calls loadModule and parseSync to check internal SQL with PostgreSQL’s own grammar. In queries it can parse, it flags functions, operators, and cast types without a schema so maintainers can fix references that search_path could resolve to the wrong object.

    View source