Classnames Converter is a VS Code extension designed to assist developers in migrating React projects from CSS Modules to Tailwind CSS (or mixing both).
It simplifies the process of wrapping class strings with the classnames library, allowing you to easily combine static Tailwind classes with dynamic CSS Module classes.
Features
🔄 One-Command Conversion: Convert className="..." to className={classNames("...")} instantly.
📦 Auto Import: Automatically detects if classnames is imported. If not, it adds import classNames from 'classnames' to the top of your file.
🎯 Migration Ready: Perfect for projects introducing Tailwind CSS into an existing CSS Modules architecture.
Usage
Open a React file (.tsx or .jsx).
Select the className attribute or place your cursor on it.
// Before
<div className="container flex-row"></div>
Open the Command Palette (Ctrl+Shift+P / Cmd+Shift+P).
Search and select Classnames Converter: Convert to ClassNames (Command ID: classnames-converter.convertToClassNames).
The code will be transformed, and the import will be added if missing.
// After
import classNames from 'classnames';
// ...
<div className={classNames('container flex-row')}></div>;
Commands
Command
Description
classnames-converter.convertToClassNames
Convert selected className string to classNames function wrapper
Requirements
Make sure the classnames package is installed in your project: