Design Token Codemod Generator
Create automated code transformations for design token migrations. Upload your token files to compare them, define mappings, and generate a codemod.
Old Tokens
New Tokens
Token Mappings
Define token mappings and click "Generate Codemod" to see the preview here
How to Migrate Your Project to New Design Tokens
Follow these steps to migrate your codebase from old design tokens to the new token system:
- Prepare your codebase
Before running the migration, make sure to commit or back up your code. This ensures you can revert changes if needed.
- Install the codemod CLI tool
Run the following command in your terminal to install the codemod CLI:
npm install -g codemod
- Run the migration codemod
Navigate to your project directory and run:
npx codemod@latest path-to-migration-codemod --engine=workflow
Replace “path-to-migration-codemod” with the path you received from your design system team.
- Review the changes
The codemod will list all files that were modified. Review these changes carefully to ensure they look correct.
Pay special attention to:
- Imports/variables that reference design tokens
- CSS/SCSS/LESS variables using token values
- JavaScript/TypeScript token references
- Test your application
Run your application and verify that all styles and components render correctly with the new tokens.
Some components might need manual adjustment if they relied on specific values from the old token system.
- Fix any remaining issues
If you encounter any visual bugs or errors, you may need to:
- Check if any tokens were missed in the migration
- Look for dynamic token usage that the codemod couldn't detect
- Update components that depend on specific token values
Migration Tips
- Run the codemod on a feature branch first to evaluate changes
- For large projects, consider migrating one module or package at a time
- Use visual regression testing to catch unexpected visual changes
- Consider running linters and type checking after migration
This migration uses ast-grep for precise, reliable token replacements. If you find any tokens that weren't properly replaced, contact your design system team for assistance.