**esprima2** is a javascript parser written in python. It works for ECMAScript 2024 and has ~1500 unit tests.
#### Credits
1. [Ariya Hidayat](https://x.com/ariyahidayat) created the original [esprima](https://github.com/jquery/esprima) library.
2. [Kronuz](https://github.com/Kronuz/esprima-python) created a python port as [esprima-python](https://github.com/Kronuz/esprima-python), line-by-line - faithfully.
3. `esprima` library hasn't been updated since ECMAScript 2019 and `esprima-python` since ECMAScript 2017.
4. With `esprima2`, I added the missing syntax support and now we can parse modern javascript.
## Features
- Full support for [ECMAScript 2024](https://www.ecma-international.org/publications-and-standards/standards/ecma-262/>)
- Sensible [syntax tree format](https://github.com/estree/estree/blob/master/es5.md) as standardized by [ESTree project](https://github.com/estree/estree)
- Experimental support for [JSX](https://facebook.github.io/jsx/), a syntax extension for [React](https://facebook.github.io/react/)
- Optional tracking of syntax node location (index-based and line-column)
- [Heavily tested](https://esprima.org/test/ci.html) (~1500 [unit tests](https://github.com/s0md3v/esprima/tree/master/test/fixtures))
## Installation
```shell
pip install esprima2
```
## Usage
Esprima can be used to perform [lexical analysis](https://en.wikipedia.org/wiki/Lexical_analysis>)
(tokenization) or [syntactic analysis](https://en.wikipedia.org/wiki/Parsing>) (parsing) a JavaScript program.
A simple example:
```javascript
>>> import esprima
>>> program = 'const answer = 42'
>>> esprima.tokenize(program)
[{
type: "Keyword",
value: "const"
}, {
type: "Identifier",
value: "answer"
}, {
type: "Punctuator",
value: "="
}, {
type: "Numeric",
value: "42"
}]
>>> esprima.parseScript(program)
{
body: [
{
kind: "const",
declarations: [
{
init: {
raw: "42",
type: "Literal",
value: 42
},
type: "VariableDeclarator",
id: {
type: "Identifier",
name: "answer"
}
}
],
type: "VariableDeclaration"
}
],
type: "Program",
sourceType: "script"
}
```
More (and original) documentation is available here: [https://esprima.org](https://esprima.org/)
Raw data
{
"_id": null,
"home_page": "https://github.com/s0md3v/esprima2",
"name": "esprima2",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "esprima, ecmascript, javascript, parser, ast",
"author": "Somdev Sangwan (s0md3v)",
"author_email": "s0md3v@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/9f/d1/094454f10ce28013110ec5adc6f649c8fff7e0c15f30d1de509cfc1b2f2e/esprima2-5.0.1.tar.gz",
"platform": null,
"description": "**esprima2** is a javascript parser written in python. It works for ECMAScript 2024 and has ~1500 unit tests.\n\n#### Credits\n1. [Ariya Hidayat](https://x.com/ariyahidayat) created the original [esprima](https://github.com/jquery/esprima) library.\n2. [Kronuz](https://github.com/Kronuz/esprima-python) created a python port as [esprima-python](https://github.com/Kronuz/esprima-python), line-by-line - faithfully.\n3. `esprima` library hasn't been updated since ECMAScript 2019 and `esprima-python` since ECMAScript 2017.\n4. With `esprima2`, I added the missing syntax support and now we can parse modern javascript.\n\n## Features\n- Full support for [ECMAScript 2024](https://www.ecma-international.org/publications-and-standards/standards/ecma-262/>)\n- Sensible [syntax tree format](https://github.com/estree/estree/blob/master/es5.md) as standardized by [ESTree project](https://github.com/estree/estree)\n- Experimental support for [JSX](https://facebook.github.io/jsx/), a syntax extension for [React](https://facebook.github.io/react/)\n- Optional tracking of syntax node location (index-based and line-column)\n- [Heavily tested](https://esprima.org/test/ci.html) (~1500 [unit tests](https://github.com/s0md3v/esprima/tree/master/test/fixtures))\n\n## Installation\n\n```shell\npip install esprima2\n```\n\n## Usage\n\nEsprima can be used to perform [lexical analysis](https://en.wikipedia.org/wiki/Lexical_analysis>)\n(tokenization) or [syntactic analysis](https://en.wikipedia.org/wiki/Parsing>) (parsing) a JavaScript program.\n\nA simple example:\n\n```javascript\n\n >>> import esprima\n >>> program = 'const answer = 42'\n\n >>> esprima.tokenize(program)\n [{\n type: \"Keyword\",\n value: \"const\"\n }, {\n type: \"Identifier\",\n value: \"answer\"\n }, {\n type: \"Punctuator\",\n value: \"=\"\n }, {\n type: \"Numeric\",\n value: \"42\"\n }]\n\n >>> esprima.parseScript(program)\n {\n body: [\n {\n kind: \"const\",\n declarations: [\n {\n init: {\n raw: \"42\",\n type: \"Literal\",\n value: 42\n },\n type: \"VariableDeclarator\",\n id: {\n type: \"Identifier\",\n name: \"answer\"\n }\n }\n ],\n type: \"VariableDeclaration\"\n }\n ],\n type: \"Program\",\n sourceType: \"script\"\n }\n```\n\nMore (and original) documentation is available here: [https://esprima.org](https://esprima.org/)\n",
"bugtrack_url": null,
"license": "BSD-2-Clause",
"summary": "high-performance javascript parser, tokenizer and lexical analyser",
"version": "5.0.1",
"project_urls": {
"Homepage": "https://github.com/s0md3v/esprima2"
},
"split_keywords": [
"esprima",
" ecmascript",
" javascript",
" parser",
" ast"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "657e3f7a8a06e2d324a4fc1516c5ef21d29e1879ffe298eed09f710ae0e3e048",
"md5": "b8a7df1e6514ac483a3646659ce1c830",
"sha256": "edfd45faf28900d70db7d626207530e6589272be64caeeba6625cabbc121c129"
},
"downloads": -1,
"filename": "esprima2-5.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b8a7df1e6514ac483a3646659ce1c830",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 67564,
"upload_time": "2025-08-16T18:08:38",
"upload_time_iso_8601": "2025-08-16T18:08:38.949681Z",
"url": "https://files.pythonhosted.org/packages/65/7e/3f7a8a06e2d324a4fc1516c5ef21d29e1879ffe298eed09f710ae0e3e048/esprima2-5.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "9fd1094454f10ce28013110ec5adc6f649c8fff7e0c15f30d1de509cfc1b2f2e",
"md5": "d83ab8f850956671c9682d3ee4844086",
"sha256": "de3875d7529c5bb6f07f47fcc3cb1438d84368003caf1728c432c1cc7923f75b"
},
"downloads": -1,
"filename": "esprima2-5.0.1.tar.gz",
"has_sig": false,
"md5_digest": "d83ab8f850956671c9682d3ee4844086",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 5727800,
"upload_time": "2025-08-16T18:08:40",
"upload_time_iso_8601": "2025-08-16T18:08:40.464383Z",
"url": "https://files.pythonhosted.org/packages/9f/d1/094454f10ce28013110ec5adc6f649c8fff7e0c15f30d1de509cfc1b2f2e/esprima2-5.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-16 18:08:40",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "s0md3v",
"github_project": "esprima2",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "esprima2"
}