jscodeshift
Build / code quality tool · Free
An AST-based codemod toolkit: it reproducibly transforms many JavaScript and TypeScript files during API migrations.
Also known as: facebook/jscodeshift; javascript-codemod-toolkit

What you can use for free
Code and local use under MIT.
Paid features and costs
Computing resources, self-hosting, and external services are paid for separately if used.
Access and limitations
Code and local use under MIT. Computing resources, self-hosting, and external services are paid for separately if used.
Use cases
- Automate an API migration through an AST codemod
- Create an AST transform and apply it to a small file sample first
Example workflow
A possible workflow; this is not a report of hands-on testing.
Automate an API migration through an AST codemod.
Before you start
- A repository, package manifests, and configuration.
- A compatible runtime and the target build command.
Steps
- Define old and new call forms using several code examples.
- Create an AST transform and apply it to a small file sample first.
- Add the workflow to scripts or CI with a clear report.
Check your result
- A clean copy of the project reproduces the result.
- Errors produce a nonzero exit code and clear diagnostics.
Choosing jscodeshift
Automate an API migration through an AST codemod
Choose this when
- Automate an API migration through an AST codemod
- Create an AST transform and apply it to a small file sample first
Requirements
- For TypeScript, set the parser and file extensions; use dry-run to inspect without writing.
Things to consider
- Costs and limits of free use: Computing resources, self-hosting, and external services are paid for separately if used.
- Terms of use: MIT for the code; dependencies have separate licenses.
- --print alone is not a dry run: enable the no-write mode separately.
Frequently asked questions
What can you use for free in jscodeshift?
Code and local use under MIT.
What additional costs might arise with jscodeshift?
Computing resources, self-hosting, and external services are paid for separately if used.
What terms of use matter for jscodeshift?
MIT for the code; dependencies have separate licenses.
How do you get started with jscodeshift?
Define old and new call forms using several code examples. Create an AST transform and apply it to a small file sample first. Add the workflow to scripts or CI with a clear report.
Is --print enough to prevent jscodeshift from changing files?
No: --print displays the result, while --dry (-d) prevents changes from being written. For TS/TSX, separately set the parser and --extensions: the default search targets js. First check a small sample's diff, then run the project's normal checks.
License
MIT for the code; dependencies have separate licenses.
MIT — permissive license
You can use, modify, distribute, and sell the code, including in a closed-source commercial product. When sharing copies or substantial portions of the code, retain the license text and copyright notice. You do not need to open-source your entire project; the author provides no warranties.
License termsTechnologies and topics
- jscodeshift
- build
- Development