esprima2
high-performance javascript parser, tokenizer and lexical analyser
What it is and what it does
esprima2 is a JavaScript parser written in Python that converts JavaScript source code into an abstract syntax tree (AST) or token stream. It supports syntax up to ECMA 2025 and is built on a faithful Python port of the original esprima library, extended with modern ECMAScript features that the upstream projects no longer maintain. The parser produces output in the ESTree standardized format, making it compatible with tools and libraries that expect that structure.
You use it to analyze or manipulate JavaScript code from Python—tokenizing to extract individual language elements, or parsing to build a complete syntax tree for traversal, transformation, or code generation. It includes experimental JSX support and optional source location tracking. The package is backed by roughly 1500 unit tests and requires Python 3.10 or later.
Use it for:
- Static analysis of JavaScript code to detect patterns, security issues, or code quality problems.
- Building a JavaScript-to-Python transpiler or code generator that needs to understand JS syntax.
- Extracting metadata from JavaScript files (function names, imports, dependencies) for tooling.
- Linting or formatting JavaScript code by walking and inspecting its AST.
- Embedding JavaScript parsing in a Python application that processes user-supplied JS code.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Parses and tokenizes JavaScript code up to ECMA 2025 syntax, producing an ESTree-compatible abstract syntax tree or token stream for analysis and manipulation.
Yes, if you need to parse modern JavaScript from Python. The package is actively maintained, has no dependencies, installs easily, carries a permissive license, and supports current ECMAScript syntax. It is relatively new (first release July 2025) but shows active development and reasonable test coverage. No known security vulnerabilities. The main caveat is that JSX support is marked experimental, so verify it meets your needs if you rely on that feature.
Install
esprima2 on PyPI
pip
pip install esprima2uv
uv add esprima2poetry
poetry add esprima2Installing esprima2
Before you install
Low friction: pure Python wheel with no runtime dependencies. Repository is active with a recent commit on 2026-04-22 and 71 stars; first release was 2025-07-29, so it is relatively new but under active maintenance.
License in practice
BSD-2-Clause is permissive; you may use, modify, and distribute this package with minimal restrictions, provided you retain the license notice.
Quickstart
pip install esprima2
import esprima
program = 'const answer = 42'
tokens = esprima.tokenize(program)
ast = esprima.parseScript(program)
Requires Python 3.10 or later.
Verify before relying
- Whether JSX support is production-ready or remains experimental in practice.
- Performance characteristics when parsing large or complex JavaScript files.
- Completeness of ECMA 2025 syntax coverage beyond the stated feature claim.
Package facts
| License | BSD-2-Clause (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 114 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 262,895/month — #8,366 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: esprima2-6.0.0-py3-none-any.whl
Keywords: esprima, ecmascript, javascript, parser, ast
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
esprimaEsprima parses ECMAScript (JavaScript) source…
permissive · top 15,000 on PyPI
pyjsparserParses JavaScript source code into an abstract…
permissive · top 15,000 on PyPI
tree-sitter-javascriptProvides a JavaScript and JSX parser grammar…
permissive · top 5,000 on PyPI
Js2Py-3.13Js2Py translates and executes JavaScript code…
permissive · top 15,000 on PyPI
Js2PyJs2Py translates and executes JavaScript code…
permissive · top 5,000 on PyPI
tree-sitter-typescriptProvides TypeScript and TSX language grammars…
permissive · top 5,000 on PyPI
luaparserParses Lua source code into an abstract syntax…
permissive · top 15,000 on PyPI
tree-sitter-regexProvides a tree-sitter grammar for parsing…
permissive · top 5,000 on PyPI
regressProvides Python bindings to the Rust regress…
permissive · top 5,000 on PyPI
hogql-parserParses HogQL query expressions and Hog programs…
permissive · top 5,000 on PyPI