HTML to JSX Converter
Paste HTML from a template, a design tool or a code snippet and get JSX you can drop into a React component, with every attribute and style converted.
Last updated
HTML
JSX
Converted<>
{/* Sign-up card */}
<div className="card" style={{ maxWidth: "420px", padding: "24px" }}>
<h2 className="card-title">Create your account</h2>
<form onSubmit={() => { handleSubmit(event); }}>
<label htmlFor="email">Email</label>
<input type="email" id="email" name="email" defaultValue="" required autoFocus />
<label><input type="checkbox" name="updates" defaultChecked /> Send me product updates</label>
<button type="submit" className="btn btn-primary" tabIndex="0">Sign up</button>
</form>
</div>
</>Inline event handlers became arrow functions — check them, as they no longer receive a string.
value became defaultValue so the field stays editable without an onChange handler.
checked became defaultChecked so the box stays clickable without an onChange handler.
JSX needs a single root, so the elements were wrapped in a fragment (<>…</>).
Keyboard shortcuts:Ctrl ↵Copy outputCtrl SDownloadCtrl KSearch tools
How to use the HTML to JSX Converter
Paste HTML
Paste a snippet, a section or a whole page body.
Choose options
Keep or drop HTML comments, and optionally wrap the result in a component.
Review the notes
Notes explain conversions worth checking, such as event handlers and form values.
Copy into your component
Copy the JSX or download it as a .jsx file.
Features
- class → className and for → htmlFor, plus 40+ other renamed attributes (tabindex, readonly, maxlength, colspan…)
- Inline style strings become style objects, with camelCase properties and vendor prefixes
- Void elements become self-closing (<br />, <img />, <input />)
- Inline event handlers such as onclick become arrow functions with camelCase names
- value and checked on form fields become defaultValue and defaultChecked
- Comments become {/* */}, and { } in text are escaped
- Several top-level elements are wrapped in a fragment
- SVG attributes are converted to camelCase (stroke-width → strokeWidth)
- Fixes unclosed tags and tells you where
Privacy
Your HTML is processed by JavaScript in your browser tab. Nothing is uploaded or stored, and the page's security policy blocks it from sending data to any other site.
Examples
A form snippet
class, for, the void <input> and an onclick handler are all converted.
HTML
<label for="email">Email</label> <input type="email" id="email" class="input" required> <button class="btn" onclick="subscribe()">Subscribe</button>JSX
<> <label htmlFor="email">Email</label> <input type="email" id="email" className="input" required /> <button className="btn" onClick={() => { subscribe(); }}>Subscribe</button> </>Inline styles
The style string becomes an object with camelCase properties.
HTML
<div class="alert" style="background-color: #fef2f2; border-left: 4px solid #ef4444; padding: 12px 16px"> <strong>Device offline</strong> — last seen 5 minutes ago. </div>JSX
<div className="alert" style={{ backgroundColor: "#fef2f2", borderLeft: "4px solid #ef4444", padding: "12px 16px" }}> <strong>Device offline</strong>{" "} — last seen 5 minutes ago. </div>Comments, braces and two roots
Comments become {/* */}, { } in text are escaped, and a fragment wraps both elements.
HTML
<!-- Readings --> <table class="readings"> <tr><th colspan="2">dev-1042</th></tr> <tr><td>Temperature</td><td>21.4 °C</td></tr> </table> <p>Updated every {interval} seconds.</p>JSX
<> {/* Readings */} <table className="readings"> <tr> <th colSpan="2">dev-1042</th> </tr> <tr> <td>Temperature</td> <td>21.4 °C</td> </tr> </table> <p>Updated every {"{"}interval{"}"} seconds.</p> </>
Understanding JSX
How JSX differs from HTML
| HTML | JSX |
|---|---|
| class="btn" | className="btn" |
| for="email" | htmlFor="email" |
| style="font-size: 14px" | style={{ fontSize: "14px" }} |
| <br> | <br /> |
| onclick="save()" | onClick={() => { save(); }} |
| <!-- note --> | {/* note */} |
| tabindex="0" | tabIndex="0" |
Things to check after converting
- Event handlers: inline JavaScript becomes an arrow function, but it may reference globals that don't exist in your component. Usually you'll replace it with a handler function.
- Form fields:
valuebecomesdefaultValueso the field stays editable. If you need a controlled input, switch back tovalueand addonChange. <script>tags are kept as text; React doesn't run them. Load scripts another way, such as next/script.- Whitespace: JSX removes line breaks between elements, so the converter adds
{" "}wherever the HTML had a space between inline elements.
Frequently asked questions
Why does React use className instead of class?
JSX compiles to JavaScript, where class is a reserved word, so React uses the DOM property name className. Likewise for becomes htmlFor.
How are inline styles converted?
A style string becomes an object with camelCase property names: background-color becomes backgroundColor, -webkit-line-clamp becomes WebkitLineClamp. Plain numbers stay numbers; everything else becomes a string.
What happens to multiple top-level elements?
A component must return one root, so the converter wraps them in a React fragment: <>…</>.
Does it work with SVG inside HTML?
Yes. Inside an <svg>, hyphenated attributes such as stroke-width become camelCase. For turning a whole SVG file into a component, use the SVG to React tool.
Will the output work in TypeScript (TSX)?
Yes. The JSX is the same in .jsx and .tsx files. Converted event handlers may need parameter types if you add them.