esprima
A high-performance, standard-compliant ECMAScript parser producing ESTree-compatible ASTs for JavaScript tooling.
Repository Health
Technical Analysis
Esprima is one of the original high-performance ECMAScript parsers for JavaScript, converting JS source code into an ESTree-compatible abstract syntax tree (AST) that other tools can traverse and transform. It was one of the first widely-adopted parsers to expose a stable, standardized AST format, which made it a foundational dependency for a generation of linters, minifiers, code-coverage tools, and IDE tooling built in the JavaScript ecosystem.
It supports parsing modern ECMAScript syntax (through ES2017) plus JSX, and includes companion tools for tokenization, AST traversal/visiting, and syntax validation. While newer parsers like Acorn and Espree have taken over as the default in many toolchains (ESLint moved to Espree), Esprima remains widely depended upon and is still a common building block referenced in parser and static-analysis documentation.
What You Get
esprima.parseScript()/parseModule()producing an ESTree-compatible AST from JS source- Tokenizer output (
esprima.tokenize()) for lexical-analysis use cases - JSX syntax support alongside standard ECMAScript syntax
- Range/location tracking options for mapping AST nodes back to source positions
- A companion
esvalidproject for validating an AST’s syntactic correctness
Common Use Cases
- Building custom static analysis or linting rules that need a JavaScript AST to traverse
- Powering code transformation, minification, or instrumentation tools that operate on parsed JS
- Extracting tokens or source positions from JavaScript for editor tooling or syntax highlighting
- Teaching or prototyping parser/compiler concepts using a well-documented reference JS parser
Under The Hood
Architecture Esprima is a hand-written recursive-descent parser: scanner.ts and tokenizer.ts handle lexical analysis, parser.ts drives grammar-rule parsing into nodes.ts-defined ESTree node shapes, with jsx-parser.ts/jsx-nodes.ts layered on for JSX syntax and error-handler.ts/messages.ts producing standardized syntax error messages. Tech Stack It’s written in TypeScript, compiled to a browser- and Node-compatible dist/ bundle via Webpack, with no runtime dependencies — a deliberate design choice to keep it embeddable in other tools without dependency bloat. Code Quality The project has an extensive test/ directory covering ECMAScript syntax edge cases across versions, and was historically maintained to a high bar as a foundational ecosystem dependency, though it has seen very little activity or new releases since 2018-2019 as tooling gravitated to Acorn/Espree. API Design The API is intentionally minimal — parseScript, parseModule, and tokenize functions each returning a plain ESTree-shaped object — which is precisely why so many other tools were able to adopt it as a drop-in AST source with little integration work.
Used by 2 apps in this directory
Artillery
Devops · Developer Tools
Cloud-scale load testing and functional testing for APIs, WebSockets, gRPC, and headless browsers, distributed across AWS Lambda or Fargate with zero infrastructure to manage.
Hoppscotch
Developer Tools
A lightweight, offline-capable API development ecosystem for testing HTTP, GraphQL, WebSocket, MQTT, and SSE endpoints across web, desktop, and CLI.