{"id":5398,"library":"pyjsparser","title":"Pyjsparser","description":"Pyjsparser is a fast JavaScript parser for Python, based on a manual translation of esprima.js. It aims to be a comprehensible JavaScript parser for Python, supporting ECMAScript 5.1 and parts of ECMAScript 6. The library is currently at version 2.7.1, with its last release dating back to April 2019, suggesting a maintenance-level release cadence rather than active development.","status":"maintenance","version":"2.7.1","language":"en","source_language":"en","source_url":"https://github.com/PiotrDabkowski/pyjsparser","tags":["javascript","parser","ast","esprima","ecmascript"],"install":[{"cmd":"pip install pyjsparser","lang":"bash","label":"Install with pip"}],"dependencies":[],"imports":[{"symbol":"parse","correct":"from pyjsparser import parse"}],"quickstart":{"code":"from pyjsparser import parse\n\njs_code = 'var message = \"Hello, Pyjsparser!\"; console.log(message);'\nast = parse(js_code)\nprint(ast)\n\n# Example of accessing a property (structure depends on AST)\n# For illustration, this may need adjustment based on the exact AST output\n# if ast and ast['type'] == 'Program' and ast['body']:\n#     first_statement = ast['body'][0]\n#     if first_statement['type'] == 'VariableDeclaration':\n#         print(f\"Variable declared: {first_statement['declarations'][0]['id']['name']}\")","lang":"python","description":"Parses a given JavaScript string into an Abstract Syntax Tree (AST)."},"warnings":[{"fix":"For parsing modern JavaScript, consider alternative tools that are actively maintained or utilize more recent JavaScript engines.","message":"The library's last release was in April 2019. While functional, it has not received updates for newer ECMAScript features beyond ES5.1 and parts of ES6. This means it may not correctly parse modern JavaScript syntax (ES2016+).","severity":"gotcha","affected_versions":"<=2.7.1"},{"fix":"Test `pyjsparser` thoroughly with your specific Python 3 version. If issues arise, consider pinning an older, compatible Python 3 release or using an alternative parser for complex or modern use cases.","message":"Although the `pyjsparser` wheel (version 2.7.1) mentions 'py2-none-any.whl', indicating Python 2 compatibility, the library also works with Python 3. However, due to the lack of recent updates, users might encounter compatibility issues or unexpected behavior with very recent Python 3 versions. Ensure thorough testing in your target Python environment.","severity":"gotcha","affected_versions":"All versions (due to age)"},{"fix":"Review the official documentation (derived from esprima.js) for specific supported ECMAScript features if targeting anything beyond ES5.1.","message":"The documentation states support for ECMAScript 5.1 and *parts* of ECMAScript 6. Users should not expect full compatibility with all features introduced in ES6 or any subsequent ECMAScript versions. Missing features might lead to parsing errors or an incomplete AST for modern JavaScript code.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}