⚛️ HTML to React (JS)

The most advanced and robust HTML to JSX converter for VS Code.
Instantly convert complex HTML, SVG, and CSS into clean, functional React components with a single click.
✨ Why this extension?
Most simple converters use brittle regex that fails on complex HTML or breaks your text content. This extension uses a smart parsing engine designed for modern web development.
🛡️ Smart Parsing
- Preserves Content: Text content remains untouched (e.g.,
<div>class</div> stays <div>class</div>).
- Nested Structures: Perfectly handles deeply nested tags and complex layouts.
- Escape Logic: Automatically escapes curly braces
{} and other JSX-restricted characters in text content.
🎨 Premium Features
- Style Magic: Automatically transforms inline CSS into React-ready style objects.
- Form Intelligence: Converts
value ➡️ defaultValue, checked ➡️ defaultChecked, and class ➡️ className.
- Full SVG Support: Full camelCase conversion for all SVG and ARIA attributes.
- Clipboard/File Workflow: Copy directly to clipboard or save as a new
.jsx/.tsx file.
🚀 Key Features
| Feature |
Description |
| Smart Attributes |
class ➡️ className, for ➡️ htmlFor, and camelCase for events like onclick. |
| SVG Power |
Seamlessly converts stroke-width, fill-rule, and 100+ other SVG attributes. |
| Boolean Logic |
Handles checked, disabled, readonly correctly for JSX. |
| Void Tags |
Automatically closes <br>, <img/>, <input/>, etc. |
| Comments |
<!-- --> ➡️ {/* */} translation. |
| Advanced UI |
New dedicated Webview for real-time preview, TypeScript options, and state generation (Command: HTML to React: Advanced UI). |
| Customizable |
Choose between Arrow Functions and Function Declarations. |
📖 How to Use
- Select any HTML/SVG code in your editor.
- Right-click and choose "Create to JSX" (or use
Cmd+Alt+R / Ctrl+Alt+R).
- Enter a name for your component (e.g.,
Navbar).
- Choose: Save to a new file or Copy to Clipboard.
💡 Examples
Input:
<div class="form-group">
<input type="text" value="Hello" class="input" style="color: blue;" disabled>
<label for="id">Label</label>
</div>
Output:
import React from 'react';
const Navbar = (props) => {
return (
<>
<div className="form-group">
<input type="text" defaultValue="Hello" className="input" style={{ color: 'blue' }} disabled />
<label htmlFor="id">Label</label>
</div>
</>
);
};
export default Navbar;
2. SVG Icons
Input:
<svg stroke-width="2" fill-rule="evenodd">
<circle cx="12" cy="12" r="10" />
</svg>
Output:
<svg strokeWidth="2" fillRule="evenodd">
<circle cx="12" cy="12" r="10" />
</svg>
⚙️ Configuration
You can customize the extension behavior in your settings.json:
htmlToReact.componentType: "Arrow Function" (default) or "Function Declaration"
htmlToReact.fileExtension: ".jsx" (default) or ".tsx"
htmlToReact.defaultDirectory: Target folder (e.g., "src/components")
htmlToReact.autoFormat: Automatically format the file after creation (Prettier recommended)
👨💻 Author
Ganesh Wayal
GitHub | Marketplace
Enjoying the extension?
Please leave a review to help others find it! ⭐⭐⭐⭐⭐