{"id":42909,"library":"js-sql-parse","title":"JS SQL Parse","description":"A nearley-based SQL parser and analyzer for JavaScript. Current version 0.2.9 is in early development (work in progress) with support for SELECT and CREATE VIEW operations. Outputs structured analysis including referenced tables, created tables, source tables from subqueries/joins, and the parse tree. Differentiators: lightweight, no external database required, focuses on SQL analysis rather than execution. Release cadence: irregular maintenance updates.","status":"active","version":"0.2.9","language":"javascript","source_language":"en","source_url":"https://github.com/justinkenel/js-sql-parse","tags":["javascript","js","sql","parse"],"install":[{"cmd":"npm install js-sql-parse","lang":"bash","label":"npm"},{"cmd":"yarn add js-sql-parse","lang":"bash","label":"yarn"},{"cmd":"pnpm add js-sql-parse","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Grammar parser engine for SQL syntax","package":"nearley","optional":false}],"imports":[{"note":"Default export is the parse function. Named import 'parse' is incorrect; use default import or require.","wrong":"const { parse } = require('js-sql-parse')","symbol":"default (parser)","correct":"import parser from 'js-sql-parse'"},{"note":"CommonJS: require returns the default export directly, not an object with 'parse'.","wrong":"const { parse } = require('js-sql-parse')","symbol":"default (parser)","correct":"const parser = require('js-sql-parse')"},{"note":"No official TypeScript types. Use `@types/js-sql-parse` or define your own.","wrong":"","symbol":"TypeScript types","correct":"import parser from 'js-sql-parse'"}],"quickstart":{"code":"import parser from 'js-sql-parse';\n\nconst query = 'SELECT a.name, b.order_date FROM customers a JOIN orders b ON a.id = b.customer_id WHERE a.active = 1';\nconst result = parser.parse(query);\n\nconsole.log('Operation:', result.operation);\nconsole.log('Referenced Tables:', result.referencedTables);\nconsole.log('Source Tables:', result.sourceTables);\nconsole.log('Joins:', result.joins);","lang":"typescript","description":"Parses a SQL SELECT query with a JOIN and logs the analyzed properties: operation, referenced tables, source tables, and joins."},"warnings":[{"fix":"Check the operation field after parsing. For unsupported operations, consider a different SQL parser.","message":"Only SELECT and CREATE VIEW operations are supported. Other SQL statements (INSERT, UPDATE, DELETE, etc.) will not parse correctly or may throw.","severity":"gotcha","affected_versions":"all"},{"fix":"Pin to a specific version and test thoroughly before upgrading.","message":"The package is a work in progress and API may change without notice. Versions below 1.0.0 are considered unstable.","severity":"deprecated","affected_versions":"<1.0.0"},{"fix":"Inspect the `parsed` field (the Nearley parse tree) for full details.","message":"The parse result's `sourceTables` may include tables from subqueries and joins, but the exact behavior is not well-documented. Test with complex queries.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'0.2.9':16 'analysi':34,57 'analyz':11 'base':7 'cadenc':62 'creat':29,38 'current':14 'databas':52 'develop':20 'differenti':48 'earli':19 'execut':60 'extern':51 'focus':54 'includ':35 'irregular':63 'javascript':13,66 'js':1,67 'lightweight':49 'mainten':64 'nearley':6 'nearley-bas':5 'oper':31 'output':32 'pars':3,46,69 'parser':9 'progress':23 'rather':58 'referenc':36 'releas':61 'requir':53 'select':27 'sourc':40 'sql':2,8,56,68 'structur':33 'subqueries/joins':43 'support':25 'tabl':37,39,41 'tree':47 'updat':65 'version':15 'view':30 'work':21","created_at":"2026-06-05T16:57:15.041168+00:00","updated_at":"2026-06-05T16:57:15.041168+00:00","problems":[{"fix":"Use `import parser from 'js-sql-parse'` or `const parser = require('js-sql-parse')`.","cause":"Using named import { parse } instead of default import.","error":"TypeError: parser.parse is not a function"},{"fix":"Simplify the query to standard SQL; avoid dialect-specific keywords and operators.","cause":"SQL query contains unsupported syntax or dialect-specific features (e.g., MySQL backticks, PostgreSQL ILIKE).","error":"SyntaxError: Unexpected token at position X"}],"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/justinkenel/js-sql-parse#readme","github":"https://github.com/justinkenel/js-sql-parse","docs":null,"changelog":null,"pypi":null,"npm":"js-sql-parse","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}}