Skip to main content
DevTool House

HTML to JSX Converter

HTML to JSX converter

About HTML to JSX Converter

Paste HTML and get valid JSX output for React components — with class renamed to className, for renamed to htmlFor, inline styles converted to objects, and void elements self-closed.

Last reviewed

June 23, 2026

Key Features

  • Renames class to className and for to htmlFor
  • Converts inline style strings to JSX style objects
  • Self-closes void HTML elements (input, br, img)
  • Removes HTML comments, which are not valid inside JSX
  • Instant conversion without a build tool or CLI

How to Use HTML to JSX Converter

  1. 1Paste your HTML snippet or template into the input.
  2. 2Run the converter to get valid JSX output.
  3. 3Review the converted JSX for any manual adjustments needed.
  4. 4Copy and paste the result into your React component.

Migrating an HTML template to React

When moving a landing page or email template into a React component, paste each HTML section into the converter. The output is immediately usable in JSX — saving the time of manually fixing className, style objects, and self-closing tags.

What the converter changes

Attribute names are renamed inside each tag: class becomes className, for becomes htmlFor, and tabindex, readonly, maxlength, colspan, rowspan, contenteditable, crossorigin, autofocus and similar attributes get their React spelling. Bare boolean attributes such as readonly and autofocus are renamed too.

Each double-quoted style attribute becomes a style object with camelCase property names. Values are kept as strings, except unitless numbers for properties such as opacity, z-index, font-weight and flex. Void elements such as <br>, <img> and <input> are self-closed, and HTML comments are removed because <!-- --> is not valid inside JSX. The Changes Applied list shows exactly what was changed in your input.

Input and output
HTML:
<div class="card" style="margin-top: 8px; font-weight: 600">
  <label for="q">Search</label>
  <input id="q" type="text" readonly><br>
</div>

JSX:
<div className="card" style={{ marginTop: '8px', fontWeight: 600 }}>
  <label htmlFor="q">Search</label>
  <input id="q" type="text" readOnly /><br />
</div>

What you still need to change by hand

Event handlers are left as they are. In HTML, onclick="save()" holds a string of code; in React the prop is onClick and its value must be a function, such as onClick={save} or onClick={() => save()}.

SVG attributes are not renamed. Change stroke-width to strokeWidth, fill-rule to fillRule, clip-path to clipPath and xlink:href to href. If the snippet has more than one top-level element, wrap it in a parent element or a fragment (<>...</>), because a component must return a single root.

Common Problems and Fixes

"Adjacent JSX elements must be wrapped in an enclosing tag"
Your snippet has several top-level elements. Wrap them in one parent element or in a fragment: <>...</>.
"Invalid event handler property `onclick`. Did you mean `onClick`?"
Rename the handler to camelCase and pass a function instead of a string, for example onClick={handleClick}.
"Invalid DOM property `stroke-width`" in an SVG
SVG attributes keep their hyphens after conversion. Rename them to camelCase by hand: strokeWidth, strokeLinecap, fillRule and so on.
A style attribute was not converted
Only double-quoted style attributes are converted. Change style='...' to style="..." and convert again.

How It Works

The converter parses the HTML input, applies standard HTML-to-JSX transformation rules (attribute renames, style object conversion, void element self-closing), and outputs valid JSX syntax.

Privacy Notes

HTML is sent to DevTool House servers for conversion and is not stored once the result is returned. Avoid converting templates that contain secrets, authentication tokens, or sensitive server-rendered data.

Limitations

The converter handles standard HTML attributes. Custom web components, non-standard attributes, or framework-specific directives may require manual adjustments after conversion. Dynamic template syntax (e.g., PHP, Django, Jinja) is not interpreted.

Frequently Asked Questions