benjamn/recast

JavaScript syntax tree transformer, nondestructive pretty-printer, and automatic source map generator

View on GitHub ↗Jump to charts ↓Open shareable report

Summary Information

Updated 26 minutes ago
Added to GitGenius on September 13th, 2026
Created on September 21st, 2012
Open Issues & Pull Requests: 200 (+0)
GitHub issues: Enabled
Number of forks: 363
Total Stargazers: 5,253 (+0)
Total Subscribers: 43 (+0)

Repository Insights (GitGenius)

Median issue/PR response: 213.2 days
Mean response time: 438.1 days
90th percentile: 941.0 days
Tracked items: 14

Most active contributors

Sign in to see contributor activity.

Charts & Analytics

Fetching additional details & charts...

Issue Activity (beta)

Open issues: 13
New in 7 days: 0
Closed in 7 days: 0
Avg open age: 1,077 days
Stale 30+ days: 12
Stale 90+ days: 9

Recent activity

Opened in 7 days: 0
Closed in 7 days: 0
Comments in 7 days: 0
Events in 7 days: 0

Top labels

No label distribution available yet.

Most active issues this week

No issue events were indexed in the last 7 days.

Detailed Description

Recast is a JavaScript syntax tree transformer that preserves original formatting when reprinting modified code and automatically generates source maps.

The tool solves the problem of code transformation while maintaining readability and style. When you parse JavaScript code with Recast, it creates a shadow copy of the abstract syntax tree and tracks the original source through a special property on each node. As you modify the tree, Recast's print function detects which nodes changed and reprints only those parts using a generic pretty printer, leaving everything else exactly as it was in the original source. If no modifications touch a section of code, that section is guaranteed to remain byte-for-byte identical to the input.

Recast suits projects that need to transform code while preserving developer intent and formatting choices—particularly useful for code generators, linters, refactoring tools, and automated transformations where maintaining the original style matters. The tool works with any parser that implements a parse method; while it defaults to Esprima for standard JavaScript, you can configure it to use parsers that support TypeScript, Flow, or other syntax extensions by passing a custom parser to the parse function. The key requirement is calling Recast's parse method rather than parsing separately, since that's what enables the original-tracking mechanism that powers the conservative reprinting.

Development activity shows consistent maintenance with regular CI workflows validating changes. The project maintains active community engagement through a chat channel for discussion and questions. Documentation is thorough, with detailed guidance on the AST API through the ast-types module and clear examples demonstrating both the conservative reprinting behavior and the fallback pretty-printer for cases where modifications cannot use original source text.