talira

Acorn (JavaScript parser)

A tiny, fast JavaScript parser written in JavaScript

open sourceMITfree

Acorn is a small, fast JavaScript parser written in JavaScript. parse() turns source code into an abstract syntax tree in the ESTree format, for the ECMAScript version you choose or the latest it supports. Its repository also publishes acorn-loose, an error-tolerant parser, and acorn-walk, a syntax tree walker, and plugins can extend the parser. It isn't the archived Acorn Kubernetes platform.

Problems it solves

  • parse JavaScript source into an AST from a Node.js tool
  • walk a JavaScript syntax tree to find function calls or imports
  • parse partly broken JavaScript without throwing on the first error

Features

  • parse() returns an ESTree abstract syntax tree
  • ecmaVersion option, from a year or version number to "latest"
  • acorn-loose, an error-tolerant parser
  • acorn-walk, a syntax tree walker
  • ESM and CommonJS builds, with TypeScript types