HTML to JSX Converter
Convert HTML to React JSX. Handles className, htmlFor, self-closing tags, camelCase styles, and more: right in your browser.
HTML Input
JSX Output
What Is an HTML to JSX Converter?
Moving HTML from a design file or a CMS into a React component? That copy-paste almost never works cleanly. JSX has its own rules: class becomes className, for becomes htmlFor, void elements need a self-closing slash, and inline styles must be objects instead of strings. This tool handles all of that automatically. Paste your HTML and get back valid JSX you can drop straight into a component. The React JSX documentation covers the full spec if you want to understand why these differences exist.
The page reads your markup tag by tag, so only attribute names inside real tags change. A paragraph that mentions class= or the word readonly comes out exactly as you wrote it, apart from {, } and >, which JSX cannot hold in plain text and which become {, } and > (they render the same). Inline handlers get React names and become functions, so onclick="save()" turns into onClick={(event) => { save(); }}. Comments become {/* */}, a <!DOCTYPE> is dropped, and several top-level elements are wrapped in a <> fragment. Tags are not re-nested or closed for you, so check the result in the Babel online playground, and look up the HTML side of any attribute on MDN Web Docs.
How to Use This Tool
Paste your HTML
Drop your markup into the HTML Input pane, or let Upload read an .html, .htm or .txt file. Hit Sample for a profile card with a label for, a read-only input with maxlength, a red inline style and a table using colspan, so most of the rename rules fire at once.
Read the JSX on the right
The JSX shows up on the right shortly after your last keystroke. Attributes are renamed, void elements get />, inline styles become objects, and a value or checked on an input turns into defaultValue or defaultChecked so React does not treat the field as locked.
Copy or download the JSX
Click Copy to grab the JSX output, or Download to save it. To clean up messy HTML before converting, try the HTML Cleaner tool first.
Conversion Example
Here is what a typical HTML snippet looks like before conversion. Paste it in and see the JSX output on the right:
HTML input
When You Actually Need This
The most common use case is migrating a static HTML template into a React component. Designers hand off HTML, you need JSX: this bridges that gap in seconds. It's also useful when copying examples from documentation sites, Stack Overflow, or CodePen into a React project. The React createElement API is what JSX compiles to, and understanding the attribute mapping helps when you hit edge cases. For projects where you want to avoid JSX entirely, the htm library is a lightweight alternative worth knowing about.
If you need to inspect the rendered output of your JSX as HTML, try the HTML Viewer tool.
Frequently Asked Questions
Does this handle all JSX attribute differences?
It covers the ones you meet in real markup: class→className, for→htmlFor, tabindex→tabIndex, readonly→readOnly, maxlength→maxLength, colspan→colSpan, autocomplete→autoComplete, srcset→srcSet and about forty more, every on… handler (ondblclick→onDoubleClick, onkeydown→onKeyDown), and hyphenated SVG names such as stroke-width→strokeWidth. data- and aria- attributes stay as they are. The full differences are listed in the React DOM components reference.
How does the inline style conversion work?
Style strings like style="color: red; font-size: 14px" become React object syntax: style={{ color: 'red', fontSize: '14px' }}. Hyphenated properties are camelCased, -webkit- prefixes become Webkit…, custom properties such as --brand keep their name as a quoted key, and a semicolon inside url(...) does not split the declaration.
Which elements get self-closed?
All HTML void elements: area, base, br, col, embed, hr, img, input, link, meta, param, source, track, and wbr.
Is my code sent to a server?
No. The attribute renaming and style rewriting all happen in JavaScript on this page, and your markup is never transmitted.
Can I use this for TSX files too?
Yes. The output is valid JSX which is also valid TSX. Just add your TypeScript types around it after pasting into your .tsx file.
Related Tools
The React JSX documentation explains the full set of differences between HTML and JSX. The MDN HTML attributes reference is useful for understanding the HTML side.