HTML to JSX Converter - Free Online Tool
Convert HTML to JSX online for free. Automatically transforms class to className, style strings to objects, and fixes self-closing tags.
What is HTML to JSX?
How to Use HTML to JSX
Paste your HTML code into the input area. Click "Convert" to transform it to valid JSX. The tool automatically converts class to className, for to htmlFor, inline styles to JavaScript objects, and makes void elements self-closing. For example, <div class="box" style="color: red"> becomes <div className="box" style={{color: "red"}}>. Copy the JSX output with one click.
How HTML to JSX Works
Common Use Cases
- Migrating existing HTML templates into React or Next.js components
- Converting HTML email templates to JSX for React Email or similar libraries
- Bringing HTML snippets from design tools (Figma exports, Bootstrap components) into React projects
- Converting HTML documentation examples to JSX for React-based documentation sites
- Quickly adapting HTML prototypes or CodePen experiments into React components
- Converting inline style attributes to React-compatible style objects
Frequently Asked Questions
What HTML attributes are converted?▼
The converter transforms class to className, for to htmlFor, tabindex to tabIndex, readonly to readOnly, onclick to onClick, and many more. All standard HTML attributes that differ in JSX are handled automatically.
Does it handle inline styles?▼
Yes. Inline style strings like style="color: red; font-size: 14px" are converted to JSX style objects: style={{color: "red", fontSize: "14px"}}. CSS property names are converted from kebab-case to camelCase.
What about self-closing tags?▼
JSX requires void elements to be self-closing. The converter automatically adds the closing slash to elements like <img>, <br>, <input>, <hr>, <meta>, and <link>.
Does it handle SVG elements?▼
Yes. SVG attributes like stroke-width, fill-opacity, and xmlns are converted to their JSX equivalents (strokeWidth, fillOpacity). SVG is commonly used in React components and the converter handles these cases.
Can I convert entire HTML pages?▼
You can convert any amount of HTML, from a single element to a full page template. For entire pages, you may need to manually add the React component wrapper (function/class declaration and return statement) around the converted JSX.
Does it handle data- and aria- attributes?▼
Yes. Custom data-* attributes and aria-* accessibility attributes are passed through unchanged, as they are valid in both HTML and JSX without modification.