Skip to main content
Help us improve Python packaging – donate today!

ECMAScript parsing infrastructure for multipurpose analysis in Python

Project Description

[![PyPI version](](
[![PyPI downloads](](

**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)](

### Features

- Full support for ECMAScript 2017 ([ECMA-262 8th Edition](
- Sensible [syntax tree format]( as standardized by [ESTree project](
- Experimental support for [JSX](, a syntax extension for [React](
- Optional tracking of syntax node location (index-based and line-column)
- [Heavily tested]( (~1500 [unit tests]( with [full code coverage](

### Installation

pip install esprima

### API

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

Release history Release notifications

History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


This version
History Node


History Node


History Node


History Node


Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
esprima-4.0.0.dev3.tar.gz (43.5 kB) Copy SHA256 hash SHA256 Source None Jul 17, 2017

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page