sqlingo API Reference
A TypeScript port of SQLGlot, the popular Python SQL parser. Parse, transpile, optimize, and build SQL across 32 dialects, in the browser or Node.js.
sqlingo reads SQL in one dialect, builds an abstract syntax tree (AST), and writes it back in another dialect. This means DATE_SUB(d, INTERVAL 1 DAY) in MySQL becomes d - INTERVAL '1 DAY' in Postgres, without string manipulation.
import { transpile } from "sqlingo";
import { MySQL } from "sqlingo/mysql";
import { Postgres } from "sqlingo/postgres";
const [sql] = transpile("SELECT DATE_SUB(d, INTERVAL 1 DAY) FROM t", {
read: MySQL,
write: Postgres,
});
// "SELECT d - INTERVAL '1 DAY' FROM t"What you get
Parsing: every SQL string becomes a typed AST you can inspect, search, and transform. Transpiling: convert between 32 dialects with automatic function, type, and syntax mapping. Optimization: given schema information, the optimizer qualifies columns, simplifies conditions, and eliminates dead code. Building: construct queries programmatically with a fluent API that produces the same AST.
Documentation
Start with the quick start, then work through the guide. The reference pages are for lookup once you know what you need.
Quick start: install, parse your first query, transpile between two dialects
Guide: the core workflow from parsing to transpiling, optimizing, and building
Reference: the full Expression API and all 32 dialect imports
FAQ: common questions and troubleshooting
Roadmap
sqlingo tracks SQLGlot upstream. Planned work:
Catch up with SQLGlot v26 (PRQL dialect, improved type inference)
WASM build for zero-dependency browser usage
Schema extraction from DDL statements
Performance benchmarks against the Python implementation
Links
Changelog for release history
GitHub for source code
Issues for bug reports and feature requests
npm for the published package
Playground to try it in the browser