acorn

A tiny, fast JavaScript parser that turns source code into ESTree-compliant abstract syntax trees.

Library
npm
v8.19.0
11,463 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
76 /100 Good
Development Activity 84
Maintenance 44
Community 76
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
86 /100 Excellent
Architecture 90
Code Quality 88
Innovation 85
Learning Curve 60

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 Parser class 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

TypeScript
91%
Other

FastGPT

AI Agents · AI Development

29,900

Build, debug, and deploy knowledge-based AI agents with a visual workflow editor, RAG retrieval, and support for any OpenAI-compatible LLM.

View details
93
Repo Health
84
Technical
66
Dependency
Built with
TypeScript 91%
Updated 5 days ago
TypeScript
91%
Other

FastGPT

AI Agents · AI Development

29,900

Build, debug, and deploy knowledge-based AI agents with a visual workflow editor, RAG retrieval, and support for any OpenAI-compatible LLM.

View details
93
Repo Health
84
Technical
66
Dependency
Built with
TypeScript 91%
Updated 5 days ago
TypeScript
68%
MIT

Hoppscotch

Developer Tools

80,676

A lightweight, offline-capable API development ecosystem for testing HTTP, GraphQL, WebSocket, MQTT, and SSE endpoints across web, desktop, and CLI.

View details
91
Repo Health
83
Technical
62
Dependency
Built with
TypeScript 68%
Vue 24%
Updated 6 days ago
TypeScript
68%
MIT

Hoppscotch

Developer Tools

80,676

A lightweight, offline-capable API development ecosystem for testing HTTP, GraphQL, WebSocket, MQTT, and SSE endpoints across web, desktop, and CLI.

View details
91
Repo Health
83
Technical
62
Dependency
Built with
TypeScript 68%
Vue 24%
Updated 6 days ago
TypeScript
91%
Apache 2.0

HyperFrames

AI Design Tools · AI Development

70,938

Turn plain HTML and CSS into deterministic, pixel-perfect MP4 videos — authored by humans or AI agents, rendered by headless Chrome and FFmpeg.

View details
84
Repo Health
83
Technical
65
Dependency
Built with
TypeScript 91%
Updated 5 days ago
TypeScript
91%
Apache 2.0

HyperFrames

AI Design Tools · AI Development

70,938

Turn plain HTML and CSS into deterministic, pixel-perfect MP4 videos — authored by humans or AI agents, rendered by headless Chrome and FFmpeg.

View details
84
Repo Health
83
Technical
65
Dependency
Built with
TypeScript 91%
Updated 5 days ago
TypeScript
98%
MIT

Kimi Code CLI

AI Agents · AI Code Assistants · Developer Tools

7,983

A single-binary, terminal-native coding agent that reads, edits, and runs code end to end, built by Moonshot AI for Kimi models but pluggable with Anthropic, OpenAI, and Google providers too.

View details
83
Repo Health
87
Technical
67
Dependency
Built with
TypeScript 98%
Updated 6 days ago
TypeScript
92%
Other

n8n

Automation · No Code Platforms

208,437

Code when you need it, UI when you don't — the workflow automation platform built for technical teams who refuse to choose.

View details
95
Repo Health
87
Technical
62
Dependency
Built with
TypeScript 92%
Updated 6 days ago
TypeScript
92%
Other

n8n

Automation · No Code Platforms

208,437

Code when you need it, UI when you don't — the workflow automation platform built for technical teams who refuse to choose.

View details
95
Repo Health
87
Technical
62
Dependency
Built with
TypeScript 92%
Updated 6 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers