Skip to content
Branch: master
Go to file
This branch is 45 commits ahead of forward:master.

Latest commit

dependabot-preview committed 3c45a18 May 5, 2020
Bumps [jest]( from 25.5.4 to 26.0.0.
- [Release notes](
- [Changelog](
- [Commits](facebook/jest@v25.5.4...v26.0.0)

Signed-off-by: dependabot-preview[bot] <>


Failed to load latest commit information.
Latest commit message
Commit time

SQL Parser

NPM version jsDelivr CDN Build Status

SQL Parser is a lexer, grammar and parser for SQL written in JS. Currently it is only capable of parsing fairly basic SELECT queries but full SQL support will hopefully come in time. See the specs for examples of currently supported queries.


The package is distributed on NPM and can be installed with...

npm install sql-parser-mistic

To build from source you'll need to run the following from the root of the project...

npm install
npm run compile

Tests are written using Mocha and can be run with...

npm test


The lexer takes a SQL query string as input and returns a stream of tokens in the format

['NAME', 'value', lineNumber]

Here is a simple example...

lexer.tokenize('select * from my_table')


The tokenized output is in a format compatible with JISON.


The parser only currently supports SELECT queries but is able to produce a Select object with properties for where, group, order, limit. See lib/ for more info of the returned object structure. Calling .toString() on a Select object should give you back a well formatted version of the original SQL input.

tokens = lexer.tokenize("select * from my_table where foo = 'bar'")

  FROM `my_table`
  WHERE `foo` = 'bar'


Contributions in the form of pull requests that add syntax support are very welcome but should be supported by both Lexer and Parser level tests.

You can’t perform that action at this time.