Back to browse
GitHub Repository

Pure JavaScript port of SQLite's LALR(1) SQL parser with improved error messages

66 starsTypeScript

JavaScript port of SQLite's parser, 2x-200x faster than others

by jitl·May 12, 2026·2 points·0 comments

AI Analysis

●●●BangerWizardryBig Brain

Patched Lemon to dump parse tables to JSON for a 200x speedup.

Strengths
  • Patching the Lemon parser generator to emit TypeScript is a clever hack.
  • Zero WebAssembly overhead means instant startup in browser environments.
  • Already shipped in production at Notion, proving real-world stability.
Weaknesses
  • Niche utility limited to developers specifically needing JS-based SQL parsing.
  • Maintenance burden of manually syncing with upstream SQLite grammar changes.
Target Audience

JavaScript developers building SQL tools or editors

Similar To

node-sql-parser · pgsql-ast-parser · sql.js

Post Description

I needed a SQLite parser small and fast enough to use in Notion's UI thread that I can trust will handle modern SQLite syntax. The most-downloaded SQLite parser on NPM is unfortunately unmaintained and slow, and while there are some fast and accurate WASM options, WASM pays a very large start-up cost as well as per-call overhead.

SQLite uses a LALR(1) parser generator call Lemon (similar to Yacc). I patched Lemon to dump its parse tables to JSON, then ported SQLite's [parse.y][] grammar to TypeScript with some help from Claude. The result is this library, which I think is the fastest JavaScript SQL parser out there:

~2.5x faster than liteparser (wasm) ~6x faster than @guanmingchiu/sqlparser-ts (wasm) ~10x faster than node-sql-parser ~100x faster than pgsql-ast-parser ~200x faster than sqlite-parser ~250x faster than @appland/sql-parser

This shipped in Notion a few weeks ago and cleared up some sporadic crash reports where the library we previously used choked on valid input.

parse.y: https://github.com/justjake/sqlite3-parser-js/blob/main/vend...

Similar Projects

Developer Tools●●Solid

An Embeddable SQLite Parser

424k statements/sec with zero dependencies — sqlparse can't match this performance.

WizardryNiche Gem
marcobambini
103mo ago