Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?


Failed to load latest commit information.
Latest commit message
Commit time
November 24, 2020 15:57
November 24, 2020 14:42
June 28, 2017 16:06
June 28, 2017 16:06
November 14, 2019 11:43
November 24, 2020 16:00
August 30, 2019 15:05

JS SQL Parse


Currently a work in progress: The end goal is to be able to parse and analyze general sql queries.


JS SQL Parse uses Nearley to parse strings. The grammar is defined in


Run tests using npm run test


The test files in ./tests are the best place to see examples of use. A basic example is:

const parser = require('js-sql-parser');
const result = parser.parse('select * from test_table');

The result of the parse method will have the following fields:

  • referencedTables: a list of tables used in the query
  • createdTables: a list of tables created in the query
  • sourceTables: a list of tables sourced in subqueries and joins
  • operation: the operation defined in the query - currently only select and create_view are supported
  • parsed: the resulting parse tree
  • joins: a list of joins within the query, and the columns used