{"id":43472,"library":"node-sqlparser","title":"node-sqlparser","description":"A SQL parser for Node.js that generates an AST from SQL statements and can stringify AST back to SQL. Current version 1.0.4 is the latest stable release, with no active development since 2016. Written in pure JavaScript, it uses PEG.js for parsing and supports SQL syntax inspired by various databases like MySQL, PostgreSQL, BigQuery, and PL/SQL. Compared to alternatives like node-sql-parser (with ongoing support), this package is minimal and was historically used by Alibaba's nQuery project. No TypeScript types or ES module support; requires Node >=0.8.0.","status":"abandoned","version":"1.0.4","language":"javascript","source_language":"en","source_url":"git://github.com/alibaba/nquery","tags":["javascript","sql parser","sql ast","custom sql"],"install":[{"cmd":"npm install node-sqlparser","lang":"bash","label":"npm"},{"cmd":"yarn add node-sqlparser","lang":"bash","label":"yarn"},{"cmd":"pnpm add node-sqlparser","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The package is ESM-compatible if using ES modules; however, the original documentation shows CommonJS usage. Both work.","wrong":"const parse = require('node-sqlparser').parse","symbol":"parse","correct":"import { parse } from 'node-sqlparser'"},{"note":"Same as parse; both are named exports from the module.","wrong":"const stringify = require('node-sqlparser').stringify","symbol":"stringify","correct":"import { stringify } from 'node-sqlparser'"},{"note":"AST is a constructor function that can be instantiated with 'new'.","wrong":"const AST = require('node-sqlparser').AST","symbol":"AST","correct":"import { AST } from 'node-sqlparser'"},{"note":"Default export is not documented; the package likely does not have a default export. Prefer named imports.","wrong":"const sqlparser = require('node-sqlparser')","symbol":"default export","correct":"import sqlparser from 'node-sqlparser'"}],"quickstart":{"code":"import { parse, stringify } from 'node-sqlparser';\nconst sql = 'SELECT * FROM users WHERE age > 18';\nconst ast = parse(sql);\nconsole.log(JSON.stringify(ast, null, 2));\nconst reconstructed = stringify(ast);\nconsole.log(reconstructed);\n// Expected output: SQL string similar to input","lang":"javascript","description":"Parses a SQL query into an AST and then stringifies it back to SQL. Demonstrates the two main static functions."},"warnings":[{"fix":"Consider migrating to actively maintained alternatives such as node-sql-parser (npm: node-sql-parser) or @babel/parser for SQL.","message":"No active maintenance since 2016. Security vulnerabilities or compatibility issues may exist.","severity":"breaking","affected_versions":">=0.0.0"},{"fix":"Switch to an alternative library. Node compatibility may break in future Node releases.","message":"Package is abandoned; no updates for over 8 years.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"If you need advanced SQL parsing, use a more comprehensive parser like node-sql-parser or antlr4-based parsers.","message":"The parser may not support modern SQL syntax (CTEs, window functions, etc.) or complex joins. Test your specific SQL patterns.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use a community-provided types package if available, or avoid TypeScript with this library.","message":"No TypeScript type declarations are provided; you must write your own or use @ts-ignore.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'0.8.0':93 '1.0.4':25 '2016':36 'activ':33 'alibaba':80 'altern':62 'ast':12,19,98 'back':20 'bigqueri':57 'compar':60 'current':23 'custom':99 'databas':53 'develop':34 'es':88 'generat':10 'histor':77 'inspir':50 'javascript':40,94 'latest':28 'like':54,63 'minim':74 'modul':89 'mysql':55 'node':2,65,92 'node-sql-pars':64 'node-sqlpars':1 'node.js':8 'nqueri':82 'ongo':69 'packag':72 'pars':45 'parser':6,67,96 'peg.js':43 'pl/sql':59 'postgresql':56 'project':83 'pure':39 'releas':30 'requir':91 'sinc':35 'sql':5,14,22,48,66,95,97,100 'sqlparser':3 'stabl':29 'statement':15 'stringifi':18 'support':47,70,90 'syntax':49 'type':86 'typescript':85 'use':42,78 'various':52 'version':24 'written':37","created_at":"2026-06-05T16:59:57.907198+00:00","updated_at":"2026-06-05T16:59:57.907198+00:00","problems":[{"fix":"Run 'npm install node-sqlparser' to install.","cause":"Package not installed or not in node_modules.","error":"Error: Cannot find module 'node-sqlparser'"},{"fix":"Use 'import { parse } from 'node-sqlparser'' or 'const { parse } = require('node-sqlparser')'.","cause":"Importing incorrectly; parse is a named export.","error":"TypeError: parse is not a function"},{"fix":"Simplify your SQL or use a different parser that supports your dialect. Check the parser's grammar.","cause":"SQL syntax not supported by the parser.","error":"SyntaxError: Unexpected token (your SQL)"},{"fix":"Use 'import { AST } from 'node-sqlparser'' or 'const { AST } = require('node-sqlparser')'.","cause":"Trying to use the AST constructor without importing it correctly.","error":"ReferenceError: AST is not defined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/alibaba/nquery#readme","github":"git://github.com/alibaba/nquery","docs":null,"changelog":null,"pypi":null,"npm":"node-sqlparser","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}