HTML to JSX: Every Change React Needs and How to Make Them Fast
Why pasted HTML breaks in React, the attribute and style changes JSX needs, and a quick workflow for turning templates into clean components.

Sooner or later every React developer pastes a block of HTML into a component and watches the editor turn red. The markup came from a landing page template, a design handoff, an email from a colleague or an old jQuery site, and it looked fine in the browser. JSX, however, is not HTML. It is a syntax for JavaScript function calls that happens to look like HTML, and the small differences add up quickly in a long template.
The differences that break pasted markup
The most common error is the attribute class. In JavaScript, class is a reserved word, so React uses the DOM property name className instead. The same thing happens to for on labels, which becomes htmlFor. A long list of other attributes follows the DOM property spelling too: tabindex becomes tabIndex, maxlength becomes maxLength, readonly becomes readOnly, colspan becomes colSpan, and autocomplete becomes autoComplete. React warns in the console about most of these, but only after the component renders.
The second problem is inline styles. In HTML, style is a string such as color: red; font-size: 12px. In JSX it must be an object with camelCase keys: style={{ color: "red", fontSize: "12px" }}. Vendor prefixes have their own rule, so -webkit-transition becomes WebkitTransition with a capital W, while -ms-transform becomes msTransform with a small m. Custom properties such as --gap stay as quoted keys. Some properties, such as z-index, opacity and font-weight, can take plain numbers.
The third problem is unclosed tags. HTML lets you write <br>, <img src="a.png"> and <input type="text"> without closing them. JSX requires every element to close, so these become <br /> and so on. HTML also tolerates a list item or paragraph that is never closed; JSX does not.
Finally, comments and braces. An HTML comment is a syntax error in JSX and must become {/* comment */}. A curly brace in normal text, such as a price template written as {plan}, starts a JavaScript expression in JSX, so it has to be written as a string inside braces to appear as a character.
A quick workflow
Open the HTML to JSX Converter and paste the markup into the HTML box, or open the .html file from your device. The converter parses it the forgiving way a browser does, so missing end tags for paragraphs and list items are fine. Then decide on the output:
- JSX or TSX. For a TypeScript project, choose TSX; the wrapper gets a JSX.Element return type.
- Component name. It must start with a capital letter, because React treats lower-case names as HTML tags.
- Wrapper. With Wrap in a component on, you get a complete file with export default function, ready to save and import.
- Form inputs. Leave Controlled inputs off for now. Values become defaultValue, which is right when React does not manage the field yet. When you add state later, switch to value with an onChange handler.
The notes panel lists what changed: how many elements were converted, how many attributes were renamed, how many style strings became objects, and any warnings. Read the warnings, because they mark the parts that need a human.
What still needs you
Inline event handlers. An attribute such as onclick="save()" is a string of code. In React, handlers must be functions, and the function usually lives in the component. By default the converter removes these handlers and lists each one, so nothing silently breaks. If you prefer, turn on Keep inline event handlers to get onClick={() => { save(); }} as a starting point, then replace it with a real handler.
Scripts. React does not run script tags placed in JSX. The converter keeps the code as a string and warns you. Move it into a useEffect hook or an imported module.
Templating tags. If your HTML contains Handlebars, Liquid, PHP or Blade tags, convert the rendered HTML instead. The converter treats template syntax as text.
Structure. A whole landing page pasted as one component is hard to maintain. After converting, split repeated parts, such as cards or list items, into smaller components and pass the changing data as props.
SVG icons
SVG has many dashed attributes, such as stroke-width, stroke-linecap and fill-rule, which React wants in camelCase. The converter handles them, keeps the capital letters in element names like linearGradient and clipPath, and fixes viewBox when an editor has written it in lower case. For whole SVG files exported from a design tool, with metadata and editor namespaces, a dedicated SVG cleaner gives tidier results.
Checking the result
Paste the output into your project and run your formatter and linter. Look at the browser console when the component first renders: React warns about any unknown DOM property it receives. If a form behaves oddly, check whether you need value with state or defaultValue without it. With those few checks, converting a template takes minutes instead of an afternoon of hunting for the last class attribute.



