</>
HTML JSX
React Dev Tool
Options:
HTML Input
JSX Output
JSX will appear here…
Ready

HTML to JSX Converter — Free Online React Converter

Updated May 17, 2026
Share & Support

What's included

Features

class → className — all class attributes converted for JSX compatibility in React
for → htmlFor — label for attributes converted to their React JSX equivalent
Event handlers camelCased — onclick/onkeydown/onmouseover → onClick/onKeyDown/onMouseOver
Inline styles → JS objects — CSS property strings parsed, camelCased, and objectified; convert those CSS values to Tailwind classes with our CSS to Tailwind converter
Void element self-closing — <br>, <img>, <input>, <hr> converted to self-closed form
HTML comments → JSX comments — <!-- --> converted to {/* */} throughout
Boolean attributes normalized — disabled, checked, readonly handled for JSX
Wrap in component toggle — outputs a complete named default-exported functional component
Real-time conversion — output updates instantly as you type or paste, no button needed
100% client-side — no data sent to any server, safe for proprietary HTML templates; format the source HTML first with our HTML Formatter

About this tool

Paste HTML, Get Valid JSX — class→className, Inline Styles, and Event Handlers Converted

Runs in your browser
No install or signup
Free forever

You copied an HTML template from a CMS, a design tool, or a tutorial and pasted it into a React component — and now you have a wall of compile errors because class needs to be className, for needs to be htmlFor, style="background-color: red" needs to be style={{ backgroundColor: "red" }}, and onclick needs to be onClick. Fix all of them at once in one paste.

This converter handles every HTML-to-JSX transformation automatically: classclassName (because class is a reserved JavaScript keyword), for on labels → htmlFor, inline style strings → JavaScript objects with camelCased property names (background-color: red; font-size: 16px{{ backgroundColor: "red", fontSize: "16px" }}), all on* event attributes → camelCase React equivalents (onclickonClick, onmouseoveronMouseOver, onkeydownonKeyDown), void elements (br, img, input, hr) → self-closed form (<br />), and HTML comments → JSX comments (<!-- -->{/* */}).

Paste any HTML — a single element, a component template, a CMS output block, or an email template — and the JSX output updates instantly without a button press. Toggle "Wrap in component" to get a complete named functional component ready to paste as a new file. All processing runs in your browser — safe for proprietary templates and confidential code.

Step by step

How to Use

  1. 1
    Paste your HTML into the input panelPaste any HTML markup into the left input panel — a single element, a full component template, a CMS export, an email template, or a UI kit snippet. The converter processes the input automatically and the JSX output appears in the right panel instantly as you type or paste. No button press required.
  2. 2
    Review the automatic attribute conversionsThe tool applies all HTML-to-JSX transformations in one pass: classclassName, forhtmlFor, all on* event attributes camelCased (onclickonClick, onmouseoveronMouseOver), void elements self-closed (<br />, <img />), inline style strings → JS objects (style={{ backgroundColor: "red" }}), and HTML comments → JSX comments ({/* comment */}).
  3. 3
    Toggle conversion options as neededUse the option toggles in the toolbar to control specific behaviors: Self-closing tags (add />), class → className, for → htmlFor, Camel events (camelCase all on* handlers), Style strings → objects (convert CSS strings to JS style objects), Wrap in `<>…</>` (add a JSX Fragment wrapper around multi-root markup), Export component (wrap everything in a named export const MyComponent = () => (...)).
  4. 4
    Use Prettify to clean up messy inputClick Prettify in the input panel header to normalize indentation of the source HTML before converting. This is useful when pasting from tools with inconsistent indentation — Prettify normalizes it first so the JSX output is cleanly indented.
  5. 5
    Copy or download the JSX outputClick Copy in the output panel header to copy the complete JSX to your clipboard. Click Download .jsx to save the file to disk. The output is valid JSX ready to paste directly into a .jsx or .tsx file in your React project.
  6. 6
    Use history to restore a previous conversionThe tool saves the last 18 conversions in browser localStorage. Click History to open the history panel and click any entry to restore that input. This is useful when you accidentally cleared the input or want to re-convert a previous snippet with different options.

Real-world uses

Common Use Cases

Fix className, htmlFor, and inline style errors when pasting HTML into React
Paste the HTML template here first. Copy the JSX output. Paste it into your component. No more hunting through markup to fix every class → className, every style string to a style object, and every onclick to onClick one at a time. Use our Diff Checker to verify the conversion changed only what it should.
Convert a CMS or WordPress HTML block to a React component
CMS systems output raw HTML you may want to convert to a real component rather than injecting via dangerouslySetInnerHTML. Paste the CMS output, copy the JSX, and componentize the structure without spending time on attribute syntax conversions.
Convert an HTML email template for React Email
React Email and similar libraries require JSX. HTML email templates are full of inline style attributes that all need to become style objects. Paste the raw template and get JSX that compiles without errors — inline styles included.
Understand HTML-to-JSX differences while learning React
Paste any HTML example from a tutorial or Stack Overflow and see the JSX equivalent side by side. The concrete transformation applied to your specific input is more memorable than reading abstract rules in documentation.
Clean up HTML output from an AI tool or Figma export before pasting into a component
AI code tools and design-to-code platforms often output HTML. Format it first with our HTML Formatter to normalize indentation, then paste it here to get valid JSX — verify the conversions and copy it in one step.
Quickly wrap an HTML snippet in a named React component
Enable "Wrap in component" to surround the JSX in an exported named functional component. Paste as a new .tsx file and start filling in props — the structural scaffolding is done. Apply Tailwind classes via our CSS to Tailwind converter to replace any inline styles in the output.

Got questions?

Frequently Asked Questions

JSX requires different attribute names than HTML. class must be className (class is a reserved JavaScript keyword), for on labels must be htmlFor, inline style must be a JavaScript object with camelCase properties rather than a CSS string, and event attributes like onclick must be camelCase (onClick). Void elements like br and img must be self-closed with a slash. This converter handles all of these transformations automatically.

class is a reserved keyword in JavaScript used to define ES6 classes. If JSX used the attribute name class, the JavaScript parser would throw a syntax error during compilation. React uses className instead. When React renders JSX to the real DOM, it automatically converts className back to the HTML class attribute.

HTML inline styles are CSS strings: style="background-color: red; font-size: 16px". JSX requires a JavaScript object: style={{ backgroundColor: "red", fontSize: "16px" }}. The converter parses the CSS string, camelCases every property name (background-color → backgroundColor, border-radius → borderRadius), and wraps the result in double braces.

All on* HTML event attributes are converted to camelCase React equivalents: onclick → onClick, onmouseover → onMouseOver, onkeydown → onKeyDown, onchange → onChange, onsubmit → onSubmit, onfocus → onFocus, onblur → onBlur. React uses camelCase for all event handlers consistently.

In HTML5, void elements have no closing tags. In JSX, all elements must be explicitly closed — void elements get a self-closing slash: <br />, <img />, <input />, <hr />. The converter auto-closes all recognized void elements, preventing the "JSX element has no corresponding closing tag" compile error.

Yes. Toggle "Wrap in component" to surround the JSX output in a default-exported named functional component: export default function Component() { return (...) }. Rename the placeholder name in your editor after pasting — this makes the output paste-ready as a complete new component file.

Yes. data-* and aria-* attributes are identical in HTML and JSX — they pass through unchanged. Only the attributes that differ between HTML and JSX (class, for, style, on* events) are transformed.

Paste the HTML snippet directly into the converter. All class attributes are converted to className — this includes complex Tailwind class strings and Bootstrap utility classes, which are preserved exactly as-is since JSX just changes the attribute name, not the values. If the template uses data-bs-* Bootstrap JavaScript attributes or aria- accessibility attributes, these pass through unchanged. Event handlers like onclick="myFunction()" are converted to the camelCase form onClick but their string values are left as-is — in a real component you would replace the string value with a proper JSX event handler function reference.

dangerouslySetInnerHTML is a React prop that injects a raw HTML string into the DOM without converting it to JSX: <div dangerouslySetInnerHTML={{ __html: htmlString }} />. This is appropriate when the HTML is dynamic and user-generated (a rich-text editor output, a CMS body field, a server-rendered HTML block) — content you cannot control at build time. Use this converter when the HTML is static and known at build time — a template you copied from a UI kit, documentation, or design tool. Converting to real JSX is always preferable for static content because React can manage the output correctly, whereas dangerouslySetInnerHTML bypasses React's rendering and can introduce XSS vulnerabilities if the HTML contains untrusted input.

HTML5 parsers are designed to handle missing closing tags gracefully — <br> is perfectly valid HTML. JSX is compiled by a JavaScript parser (Babel or the TypeScript compiler) that follows XML-like rules requiring every opening tag to have a closing tag or a self-closing slash. Without the slash, <br> in JSX throws a "JSX element has no corresponding closing tag" compile error that stops your build. The converter adds the required slash to all recognized void elements: br, hr, img, input, area, base, col, embed, link, meta, param, source, track, and wbr. This is a purely syntactic transformation — the rendered HTML output is identical.

The converter handles any amount of HTML markup in a single pass — paste a full page template, a multi-section layout, or an entire email template and the JSX output covers all of it. For large HTML files intended to become multiple React components, the best approach is to paste the full HTML first to get the converted JSX, then manually split it into component functions. The "Wrap in component" toggle wraps the entire output in one functional component — this is a good starting point from which to extract smaller sub-components.

Yes, and this is one of the most common use cases. HTML email templates are built with extensive inline styles (since email clients do not support external stylesheets) and many attribute-driven formatting properties. All inline style strings are converted to JavaScript style objects automatically, which is the exact format React Email and similar libraries require. After converting, replace generic HTML tags with React Email's semantic components (<Html>, <Body>, <Section>, <Text>, <Button>) as needed — the attribute conversions are already handled.