Skip to main content

ECMAScript parsing infrastructure for multipurpose analysis in Python

Project description

Donate PyPI Version PyPI License PyPI Format PyPI Status

Esprima (, BSD license) is a high performance, standard-compliant ECMAScript parser officially written in ECMAScript (also popularly known as JavaScript) and ported to Python. Esprima is created and maintained by Ariya Hidayat, with the help of many contributors.

Python port is a line-by-line manual translation and was created and is maintained by German Mendez Bravo (Kronuz).



pip install esprima


Esprima can be used to perform lexical analysis (tokenization) or syntactic analysis (parsing) of 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"

For more information, please read the complete documentation.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for esprima, version 4.0.1
Filename, size File type Python version Upload date Hashes
Filename, size esprima-4.0.1.tar.gz (47.0 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page