acorn
A tiny, fast JavaScript parser that turns source code into ESTree-compliant abstract syntax trees.
Repository Health
Technical Analysis
Acorn is a small, fast JavaScript parser written entirely in JavaScript. Given a string of source code, it produces an abstract syntax tree that conforms to the ESTree specification, supporting the full range of finalized ECMAScript features from ES3 through the latest stage-4 additions.
Designed to be embedded, Acorn is the parsing engine behind a large slice of the JavaScript toolchain — bundlers, linters, transpilers, and static-analysis tools rely on it to read code. Its extensible plugin architecture lets consumers redefine parser behavior to support JSX, custom syntax, and experimental proposals without forking the core.
What You Get
- A single
parse(input, options)function that returns an ESTree-compliant AST - Full support for finalized ECMAScript syntax from ES3 through the latest stage-4 features, selectable via
ecmaVersion - A standalone tokenizer and low-level
Parserclass you can drive directly - An extensible plugin system via
Parser.extend()for JSX, types, and custom dialects - Companion packages acorn-loose (error-tolerant parsing) and acorn-walk (tree traversal)
Common Use Cases
- Powering bundlers and build tools that need to read and transform JavaScript modules
- Building linters, formatters, and static-analysis tools on top of an ESTree AST
- Writing codemods and source transformations that inspect or rewrite code structurally
- Prototyping JavaScript dialects and experimental syntax through parser plugins
Under The Hood
Architecture - Acorn is built around a single Parser class defined in src/state.js whose behavior is composed from separate concern-focused modules that each augment the prototype: statement.js, expression.js, lval.js, location.js, and scope.js are imported for their side effects in src/index.js, extending the parser with recursive-descent methods. parse() constructs a Parser, tokenizes on demand through tokenize.js/tokentype.js/tokencontext.js, and walks the grammar to emit Node objects (node.js) matching the ESTree spec. Extensibility is a first-class design goal: Parser.extend() returns subclasses so plugins can override individual methods.
Tech Stack - The library is pure JavaScript (99.9% of the repo) with zero runtime dependencies, authored as ES modules under src/ and bundled with Rollup (rollup.config.mjs) into CommonJS, ESM, and TypeScript-typed distributions. The monorepo also houses acorn-loose and acorn-walk, tooling uses ESLint (eslint.config.mjs), and the package targets Node >=0.4.0, reflecting an emphasis on broad compatibility.
Code Quality - The codebase is mature and well-factored, splitting parsing concerns across focused files with clear naming (readToken, parseStatement, parseExpression). Test coverage is extensive: test/ holds dozens of feature-specific suites (regexp per ECMAScript year, class features, import attributes, top-level await, etc.) run via node test/run.js, plus a Test262 conformance runner (bin/run_test262.js) that validates against the official ECMAScript test suite.
API Design - The public surface is intentionally small — most consumers only need parse(input, {ecmaVersion}) — while power users can reach for the standalone tokenizer, the low-level Parser class, and the Parser.extend() plugin mechanism. Options are numerous but well-documented in the README, and ESM builds ship TypeScript definitions for editor autocompletion. The plugin API requires understanding Acorn’s internals and can break across releases, which is the main ergonomic cost of its flexibility.
Used by 42 apps in this directory
Orca
AI Agents · AI Code Assistants
An open-source Agent Development Environment that orchestrates fleets of parallel AI coding agents — Claude Code, Codex, Gemini and more — each running in its own isolated git worktree.
overleaf
Collaboration · Productivity
Open-source, real-time collaborative LaTeX editor with sandboxed compilation and full TeXLive support for self-hosted academic and research teams.
overleaf
Collaboration · Productivity
Open-source, real-time collaborative LaTeX editor with sandboxed compilation and full TeXLive support for self-hosted academic and research teams.
Payload CMS
Blogging · CMS · Developer Tools
The open-source, Next.js-native headless CMS that lives inside your /app folder and gives you a full TypeScript backend instantly.
Pixelfed
Social Media
A decentralized, self-hosted photo sharing platform built on ActivityPub for the open Fediverse.
Plasmic
CMS · Design Tools · Low Code Platforms
The open-source visual builder that lets teams design React apps and websites with drag-and-drop while integrating seamlessly with your codebase.
Plasmic
CMS · Design Tools · Low Code Platforms
The open-source visual builder that lets teams design React apps and websites with drag-and-drop while integrating seamlessly with your codebase.
Rocket.Chat
Team Chat
The secure, self-hosted team communications platform for organizations that cannot compromise on data sovereignty.
Rocket.Chat
Team Chat
The secure, self-hosted team communications platform for organizations that cannot compromise on data sovereignty.