- Home
- Code Refactoring Tools
- jscodeshift
jscodeshift
What it is
jscodeshift is a toolkit for developers who need to apply code transformations across JavaScript or TypeScript files. A codemod parses source into an abstract syntax tree, changes the tree, and generates source again. The runner applies a transform to each file and summarizes how many files remain unchanged. From the command line, you can use a local transform, point to a transform URL, or provide file paths through standard input. Parser choices include Babel, Babylon, Flow, TypeScript, and TSX, with Babel as the default. The CLI can process files in child processes, select extensions, and exclude files using ignore patterns or configuration files. A dry run previews changes without modifying files. The API supports traversing, finding, filtering, replacing, inserting, removing, and renaming syntax-tree nodes, with optional formatting when generating code. jscodeshift wraps recast, which aims to preserve existing code style. The project also includes Jest and Jasmine utilities for transform tests and guidance for debugging with VS Code. It is free and listed for Linux, macOS, Windows, and self-hosted environments.
For and against
For
- Dry-run mode previews changes without modifying files.
- Supports Babel, Babylon, Flow, TypeScript, and TSX parsing.
- Can select extensions and exclude files.
- Includes Jest and Jasmine transform-testing utilities.
Against
- Requires a local transform or transform URL.
- No free trial is listed.
- The runner must be installed through npm.
The verdict
jscodeshift provides command-line and API tools for applying AST-based transformations across project files. Its dry run, parser choices, file selection, and testing utilities support a controlled codemod workflow.
Who it suits
It suits developers building batch refactors or other codemods for JavaScript, TypeScript, or Flow projects. Its API and test utilities also fit developers who want to write and debug transforms.
On the record
- API
- The API includes traversal, filtering, and transformation methods for AST nodes.jscodeshift.com · read 5 Oct 2026
- CLI
- The command-line interface runs codemods from a local transform file, a transform URL, or a list of paths read from standard input.jscodeshift.com · read 4 Oct 2026
- Code preservation
- The toolkit wraps recast, which attempts to preserve the original code style when generating transformed source.jscodeshift.com · read 5 Oct 2026
- Code transformations
- The API provides methods to find, filter, replace, insert, remove, and rename syntax-tree nodes.jscodeshift.com · read 4 Oct 2026
- Distribution
- The documentation directs users to install jscodeshift from npm with `npm install -g jscodeshift`.jscodeshift.com · read 4 Oct 2026
- Dry run
- The CLI supports dry runs that show the effects of a codemod without changing files.jscodeshift.com · read 5 Oct 2026
- Editor integration
- The project README links instructions for configuring VS Code to debug codemods.github.com · read 4 Oct 2026
- File selection
- The CLI supports selecting file extensions and excluding files with ignore patterns or configuration files.jscodeshift.com · read 4 Oct 2026
- Formatting
- The API can convert a transformed syntax tree back to source code with optional formatting settings.jscodeshift.com · read 4 Oct 2026
- Install
- The documentation instructs users to install the runner globally with npm install -g jscodeshift.jscodeshift.com · read 5 Oct 2026
- Integration
- The project README documents a VS Code debugger setup for debugging codemods.github.com · read 5 Oct 2026
- Intended users
- The documentation describes jscodeshift as a tool for developers who build codemods to detect and transform JavaScript or TypeScript code.jscodeshift.com · read 4 Oct 2026
- License
- The project is distributed under the MIT License.github.com · read 5 Oct 2026
- Parallel processing
- The CLI can start up to a specified number of child processes to process source files; its default is max(all - 1, 1).jscodeshift.com · read 5 Oct 2026
- Parser options
- The CLI documents babel, babylon, flow, ts, and tsx as parser options.jscodeshift.com · read 5 Oct 2026
- Parsers
- The CLI lists babel, babylon, flow, ts, and tsx as parser options, with babel as the default.jscodeshift.com · read 4 Oct 2026
- Purpose
- jscodeshift is a toolkit for building and running codemods over multiple JavaScript or TypeScript files.jscodeshift.com · read 5 Oct 2026
- Recast wrapper
- The toolkit wraps recast, which aims to preserve the original code style when transforming an abstract syntax tree.jscodeshift.com · read 4 Oct 2026