HTML to JSX Converter
Convert vanilla HTML markup into clean, valid React JSX syntax with self-closing tags and attributes.
- 100% free
- Private in browser
- No signup
- No watermarks
Valid JSX Output (5 attributes/tags converted)
<div className="container">
{/* Header Section */}
<h1 className="title">Hello World</h1>
<img src="/avatar.jpg" />
<input type="email" placeholder="Email" />
<br />
</div>About HTML to JSX Converter
The HTML to JSX Converter rewrites plain HTML so it can be pasted into a React component. It changes class to className and for to htmlFor, adds the closing slash to void elements such as img, input, br, hr, meta, and link, and turns HTML comments into JSX comments. A counter shows how many attributes and tags were changed. Inline style strings, event handlers like onclick, and other attributes such as tabindex are left as they are, so fix those by hand after copying.
How to use HTML to JSX Converter
- Paste your markup into the Vanilla HTML Code box.
- Read the converted markup in the Valid JSX Output panel.
- Check the number of attributes and tags converted in the heading.
- Click Copy JSX and paste it inside the return of your component.
Key features
- Renames class to className and for to htmlFor
- Self-closes 14 void elements, including img, input, br, hr, meta, and link
- Leaves tags that are already self-closed untouched
- Converts <!-- comments --> to {/* comments */}
- Counts how many attributes and tags were changed
- Converts as you type, with one-click copy
Frequently asked questions
- How do I convert HTML to JSX?
- Paste your HTML into the Vanilla HTML Code box and the JSX appears in the output panel straight away. Click Copy JSX and paste it into your React component.
- Does it convert inline style attributes?
- No. A style string such as style="color: red" is left unchanged, while React needs an object like style={{ color: 'red' }}. Rewrite inline styles by hand or move them into a CSS class.
- Which HTML attributes are renamed?
- Only class and for. Other attributes that React spells differently, such as tabindex, onclick, maxlength, readonly, and colspan, are not renamed, so change them to tabIndex, onClick, maxLength, readOnly, and colSpan yourself.
- Which tags get a self-closing slash?
- The 14 HTML void elements: area, base, br, col, embed, hr, img, input, link, meta, param, source, track, and wbr. Other empty tags, such as an empty div, keep their separate closing tag, which is valid JSX.
- Can I paste a full HTML page?
- You can, but the result will not be a valid component as is. JSX needs one root element and no doctype, so paste only the body markup and wrap sibling elements in a fragment. The text class= or for= inside scripts or visible text is renamed too.
Related In-Depth Guides
Learn practical workflows, real-world examples, and expert tips in our comprehensive guides:
Password Entropy Explained: How Bits Measure Brute-Force Cracking Time
Understand Shannon entropy in passwords, character pool combinations, and how many seconds, years, or millennia it takes GPUs to crack modern passphrases.
How to Convert Docker Run Commands to Docker Compose YAML Files
A comprehensive developer guide to transforming complex docker run commands into clean, maintainable docker-compose.yml files.
Web Accessibility & Color Contrast (WCAG 2.1): How to Design AA & AAA Palettes
A practical guide to color contrast ratios, accessibility compliance, WCAG 2.1 AA/AAA standards, and building accessible UI palettes.
Rate this tool
Be the first to rate — helps others and improves this page.