TypeScript SQL parser and transpiler.

sqlingo is a port of SQLGlot. Parse, transpile, and optimize SQL across 32 dialects, in the browser or Node.js.

Try the playground
$ npm install sqlingo
EXAMPLE
RETURNS
A full expression tree, mirroring SQLGlot's node classes one for one.
EXAMPLE
RETURNS
Dialect quirks (quoting, date math, casts) are rewritten for the target.
EXAMPLE
RETURNS
Qualifies columns, expands stars, and folds constant predicates.

32 of 32 - one-for-one with upstream

Cloud warehouses

7 dialects
AthenaBigQueryDatabricksDremioFabricRedshiftSnowflake

Transactional SQL

8 dialects
ExasolMySQLOraclePostgresSingleStoreSQLiteTeradataTSQL

OLAP engines

8 dialects
ClickHouseDorisDuneDruidDuckDBMaterializeRisingWaveStarRocks

Query engines

7 dialects
DrillHivePrestoSolrSparkSpark2Trino

Other targets

2 dialects
PRQLTableau

At work I maintain @dbml/core, a library that converts between DBML and SQL. Under the hood it uses ANTLR, and it has not aged well:

  • The package is 33 MB. It actually broke our CI with out-of-memory errors.
  • Adding a new dialect means making the bundle even larger.
  • The parser is incomplete, with error messages like No viable alternative at....
  • After all of that, we still only support 5 dialects.

At a hackathon I stumbled on SQLGlot, which does exactly what I needed. The catch: it's Python. I tried running it via Pyodide, but the runtime is too heavy to ship.

So I started porting it to JavaScript. Two weeks in, polyglot was announced. I kept going because I wanted full control over the implementation and a reliable way to stay in sync with upstream. sqlingo mirrors SQLGlot file for file, so catching up with a new release is a diff, not a rewrite.