HTML to JSX Converter
Paste HTML and get valid JSX instantly. Converts class to className, self-closes void elements, camelCases event handlers, and optionally transforms inline styles to JSX objects.
Last updated: May 20, 2026
Find this tool useful? Support the project to keep it free!
Buy me a coffeeWhat is HTML to JSX Converter?
When building React or Next.js components, you often start with plain HTML from a design mockup, a static site, a UI kit, or a copied snippet from the web. That HTML is not valid JSX — React's JSX syntax has several differences that cause compile errors if you paste HTML directly.
This converter handles all the common transformations: `class` becomes `className`, `for` becomes `htmlFor`, void elements like `<img>` and `<input>` get self-closing slashes, event handlers like `onclick` become camelCase `onClick`, and inline `style` strings can be converted to JSX style objects. The result is paste-ready JSX that works in any React component.
How to Use HTML to JSX Converter
Paste HTML into the input area or click "Load Sample"
Toggle options: Convert Style Strings, Convert Comments, Add Fragment
The JSX output updates instantly
Copy the JSX or download it as a .jsx file
Paste directly into your React component
Common Use Cases
- React developers converting HTML mockups or design prototypes into component JSX.
- Front-end engineers migrating static HTML pages to React or Next.js apps.
- Developers copying HTML snippets from documentation, UI kits, or Tailwind component libraries into React components.
- Teams converting email HTML templates into React email components.
- Bootcamp students learning the differences between HTML and JSX syntax.
- Developers converting CMS HTML output for use in React-rendered preview components.
Example Input and Output
A simple HTML form is converted to valid JSX with className, htmlFor, and a self-closing input.
<div class="form-container">
<form id="login" onsubmit="handleSubmit()">
<label for="email">Email</label>
<input type="email" id="email" class="input-field" readonly>
<label for="password">Password</label>
<input type="password" id="password" tabindex="1">
<button type="submit" class="btn btn-primary">Sign In</button>
</form>
</div><div className="form-container">
<form id="login" onSubmit={"handleSubmit()"}>
<label htmlFor="email">Email</label>
<input type="email" id="email" className="input-field" readOnly />
<label htmlFor="password">Password</label>
<input type="password" id="password" tabIndex={1} />
<button type="submit" className="btn btn-primary">Sign In</button>
</form>
</div>Privacy
All HTML to JSX conversion runs in your browser. No code is uploaded to any server.
After converting
Run the output through ESLint with the react/jsx plugin or paste it into your IDE to catch any remaining issues. Some attributes like aria-* and data-* pass through unchanged as they are already valid in JSX.
Frequently Asked Questions
Why does React use className instead of class?
JSX compiles to JavaScript, and class is a reserved keyword in JavaScript (used to define ES6 classes). React uses className to avoid the conflict. The compiled output maps className back to the class attribute in the DOM.
What does "Convert Style Strings" do?
It converts inline style attributes from HTML format (style="color: red; font-size: 14px") to JSX object format (style={{ color: 'red', fontSize: '14px' }}). Property names are camelCased as required by React.
Why must void elements be self-closed in JSX?
JSX follows XML rules — every element must be explicitly closed. Void elements like <img>, <input>, <br>, and <hr> have no children, so they must use the self-closing form (<img />) instead of leaving the tag open as HTML allows.
What is a React Fragment and when should I use it?
A React Fragment (<> </>) lets you return multiple root elements from a component without adding an extra DOM node. Enable "Add Fragment" when your HTML has more than one top-level element.
Does this handle all JSX differences?
It handles the most common transformations. Some edge cases — like SVG attribute names, aria- attributes, data- attributes, or complex dynamic expressions — may need manual adjustment after conversion.
Is my HTML sent to a server?
No. All conversion runs in your browser. Your code never leaves your device.
Related Tools
HTML Beautifier
Format and beautify minified or messy HTML code.
HTML Minifier
Compress HTML by removing whitespace, comments, and redundant attributes — with size reduction stats.
Markdown to HTML Converter
Convert Markdown to clean, semantic HTML with live preview — GFM tables and task lists, heading IDs, a table of contents generator, four output modes, and HTML sanitization.
HTML to Markdown Converter
Convert HTML into clean, readable Markdown — preserving headings, links, images, lists, and tables.
HTML Stripper
Remove HTML tags from text, preserving line breaks and decoding HTML entities. Instant plain-text extraction from HTML.
CSS to Tailwind Converter
Convert CSS declarations to Tailwind CSS utility classes — supports margin, padding, flex, grid, typography, colors, and arbitrary value fallbacks.

