A fast parser, formatter, static analyzer, and language server for SQLite SQL.
Available as a CLI or an embeddable library via libsyntaqlite.
About
·
Performance
·
Install
·
Documentation
·
Playground
·
Contributing
Most SQL tooling treats SQLite as a variation of generic SQL. That works for common queries, but it misses SQLite-specific syntax and the differences introduced by SQLite versions and compile-time flags. syntaqlite instead builds its parser and tokenizer from SQLite's own source.
The syntaqlite CLI and language server format SQL, analyze it against your schema,
and provide completions and navigation in your editor. The analyzer works without opening a
database and can report multiple independent diagnostics in one pass.
libsyntaqlite provides the parser, formatter, and static analyzer used by the CLI
and language server. It is available through Rust and C APIs, with packages exposing the
same functionality to Python and JavaScript/WASM. The AST retains
comments and whitespace, making it suitable for migration tools, code generation, and other
source-to-source work.
The parser has been checked against roughly 396,000 statements from SQLite's upstream test suite, with about 99.7% agreement on whether a statement should parse.
Performance is a design constraint for syntaqlite. It is built for tasks that run on every keystroke in an editor as well as large, generated SQL files. The tokenizer and parser are written in C, parsing is incremental, and the library APIs reuse allocations across calls. The CLI also keeps startup overhead low.
In reproducible head-to-head throughput benchmarks, syntaqlite had the lowest total run time among the parsers, formatters, and analyzers tested. These measurements include process startup as well as time spent inside the library. See the full comparison for the numbers, methodology, and tool versions.
Install the latest release on macOS, Linux, or Windows:
curl -sSf https://raw.githubusercontent.com/LalitMaganti/syntaqlite/main/tools/syntaqlite | python3 - installYou can also install it with mise, pip, Homebrew, or Cargo:
mise use github:LalitMaganti/syntaqlite
pip install syntaqlite
brew install LalitMaganti/tap/syntaqlite
cargo install syntaqlite-cliSee the installation guide for platform-specific details.
syntaqlite fmt -e "select id,name,email from users where active=1 and role='admin' order by name"SELECT id, name, email
FROM users
WHERE
active = 1
AND role = 'admin'
ORDER BY
name;syntaqlite fmt -i query.sql formats a file in place, while --check checks formatting
without changing anything.
Give the analyzer your schema and it can find mistakes without connecting to a database.
For example, given this schema.sql:
CREATE TABLE users (id, name, email);Run:
syntaqlite analyze --schema schema.sql -e "SELECT nme, email FROM users"error: unknown column 'nme'
--> <expression>:1:8
|
1 | SELECT nme, email FROM users
| ^~~
= help: did you mean 'name'?
A syntaqlite.toml file can associate different groups of SQL files with different schema
files. The CLI and language server both use it; see the
project setup guide for an
example.
The version and compile flags are global options shared by the parser, formatter, analyzer, and language server. For example, this checks a query as SQLite 3.32.0:
syntaqlite --sqlite-version 3.32.0 analyze \
-e "DELETE FROM users WHERE id = 1 RETURNING *;"error: syntax error near 'RETURNING'
--> <expression>:1:32
|
1 | DELETE FROM users WHERE id = 1 RETURNING *;
| ^~~~~~~~~
RETURNING was added in SQLite 3.35.0. Optional SQLite features can be enabled in the same
way:
syntaqlite --sqlite-cflag SQLITE_ENABLE_MATH_FUNCTIONS analyze query.sqlPrint the full abstract syntax tree for a query:
syntaqlite parse -e "SELECT 1 + 2"The language server provides diagnostics, completion, formatting, semantic highlighting, rename, and navigation without requiring a live database connection.
- VS Code: install syntaqlite: SQLite language server and formatter.
- Zed: follow the Zed setup guide.
- Other editors: configure your LSP client to start
syntaqlite lsp; the editor guide has examples. - Claude Code: install the plugin with
claude plugin install syntaqlite@lalitmaganti-plugins.
libsyntaqlite is available in the following ecosystems:
- Rust:
cargo add syntaqlite - Python:
pip install syntaqlite - JavaScript/WASM:
npm install syntaqlite - C: parser, tokenizer, formatter, and analyzer APIs
The parser generator consumes SQLite's parse.y grammar and combines the generated parser
with SQLite's tokenizer. A small, hand-maintained layer folds the concrete syntax tree into
an AST. Keeping those decisions separate from the grammar makes SQLite version updates less
fragile.
The parser and tokenizer are C, so they can be used in the same environments as SQLite. The formatter, analyzer, and language server are written in Rust. See the architecture guide for a more detailed tour.
SQLite-based dialects can add grammar, AST nodes, functions, and formatting rules while reusing the same runtime. The custom dialect guide describes the code-generation workflow.
syntaqlite is usable today, but it is still a 0.x project. The parser, formatter, analyzer,
language server, and libsyntaqlite APIs are all available; their public APIs and
command-line interfaces may still change before 1.0.
tools/install-build-deps
tools/cargo buildThe contributing guide covers the repository layout and test commands. Changes are welcome through pull requests.
For coding: AI was used extensively for mechanical implementation, but the design, architecture, and overall shape of the project came from me. I understand all of the code and take full responsibility for it.
For other tasks: AI was used for research, brainstorming, testing, documentation, and integrations. I wrote a detailed account of how I built syntaqlite with AI, including where it helped and where it was detrimental.
Apache 2.0. The parts derived from SQLite are public domain under the SQLite blessing. See LICENSE for details.