Skip to main content

esprima2 is a javascript parser written in python. It supports syntax up to ECMA 2025 and has ~1500 unit tests.

Credits

  1. Ariya Hidayat created the original esprima library.
  2. Kronuz created a python port as 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

Installation

pip install esprima2

Development

Run the test suite with:

python3 -m test

Usage

Esprima can be used to perform lexical analysis (tokenization) or syntactic analysis (parsing) a JavaScript program.

A simple example:

    >>> 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

Metadata

Release files for esprima2 6.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for esprima2 6.0.0
File Size Uploaded
esprima2-6.0.0.tar.gz 60.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for esprima2 6.0.0
File Interpreter ABI Platform
esprima2-6.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 136.1 kB

Release files / esprima2-6.0.0.tar.gz

Download URL esprima2-6.0.0.tar.gz
Size 60.0 kB
Tags Source
SHA-256 checksum
How to use checksums
3a4f045a7171b1027ae770d4b28caf55f987f133436d569d52e221ae313d9f83
BLAKE2b-256 checksum
How to use checksums
8bb387832c18ff84010a08ea64e4c0c4c91550e0e28207b835db4849cd0aec81
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 22, 2026.

Transparency log

Release files / esprima2-6.0.0-py3-none-any.whl

Download URL esprima2-6.0.0-py3-none-any.whl
Size 76.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0596fae544e0a9d7a07b1243ee9e9016b568812c20f9a06cb8f85bbb7c2ef443
BLAKE2b-256 checksum
How to use checksums
7f10583154299cde5ba31a2818490788398c9a9cbb01292cc485d505e03b5966
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 22, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

6.0.0 This release

2 release files

5.0.2

2 release files

5.0.1

2 release files

5.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page