HTML to JSX Converter
JSX looks like HTML, but it isn't. React reuses JavaScript's variable-naming rules, which means 'class' becomes 'className', 'for' becomes 'htmlFor', and event handlers like 'onclick' become 'onClick'. Inline styles that were strings become JavaScript objects with camelCase property names. Void elements must self-close. This tool handles all of that in one paste-and-copy operation.
What Gets Converted
Attribute renames — class → className, for → htmlFor, tabindex → tabIndex, readonly → readOnly, maxlength → maxLength, and 30+ other renames. Event handlers — onclick → onClick, onchange → onChange. Only the first letter after "on" is capitalised, so multi-word events (onMouseOver, onKeyDown) and string handler values need fixing by hand. Void element self-closing — <img>, <input>, <br>, <hr> get proper <img /> syntax. Style strings to objects — 'color: red; font-size: 16px' becomes {{color: 'red', fontSize: '16px'}}. HTML comments — converted to JSX-compatible {/* */} syntax. Boolean attributes — checked, disabled, required become explicit true assignments (the same words in your text are changed too; see the worked example).
Common Use Cases
Porting a static landing page into a React component without manually fixing class vs className, for vs htmlFor, self-closing void elements, and inline-style strings on every element. Bringing a Figma-export or Webflow-export HTML snippet into a Next.js or Remix app. Cleaning up AI-generated HTML before pasting it into a JSX file so the build doesn't reject it for missing closes or stray boolean attributes.
Quickly checking what a chunk of marked-up content looks like in JSX form before committing to refactoring it into proper components — the conversion makes the syntactic friction visible at a glance. Every inline style attribute string becomes a JSX object literal, every tabindex becomes tabIndex, and every boolean attribute gets the right JSX shape, which helps scope the eventual cleanup.
Worked example: nine conversions rendered by React
The converter now works on the document your browser parses, not on the raw text, so a word in a sentence can never be mistaken for an attribute. On October 13, 2026 we converted nine awkward snippets in Chromium 141, compiled each result with Babel 7.26 and rendered it with React 18.3.1's renderToStaticMarkup, then compared the rendered DOM (tags, attributes, styles, text) with the original HTML: identical 9 of 9, with no React warnings.
| Case | Before (v215) | Now |
|---|---|---|
| Prose: "the default class for the label is open" | words rewritten: class=…, open={true} inside the sentence | text untouched: only attributes are converted |
Text with {name} | copied as is: a JSX expression, so the component threw "name is not defined" | {'{'}name{'}'}: renders the braces |
| onmouseover, ondblclick | onMouseover, onDblclick: not React events, ignored | onMouseOver, onDoubleClick from React's event list |
| onclick="submit()" | string handler: React rejects it and warns | an arrow function holding the code in a comment, plus a warning to move it |
| SVG stroke-width, fill-rule, xlink:href | left as written: React warns and drops some | strokeWidth, fillRule, xlinkHref |
| Text split across lines, e.g. "Click / <a> / to" | JSX trims the line breaks: "Clickhereto" | {' '} kept where the browser would show a space |
| input value, checked | value without onChange (read-only warning) | defaultValue, defaultChecked |
- Inline code is not kept as code. React needs functions, not strings, so
onclick="submit()"becomesonClick={() => { /* submit() */ }}and is listed under the output; move the logic into the function yourself. Inline<script>blocks are turned into a comment, because React does not run them. - Comments survive as JSX comments,
{/* note */}, and<pre>text is emitted as a string so its spaces and line breaks stay exact. - Selected options.
<option selected>is kept but flagged: in React the selected option is set withdefaultValueon the<select>.
Sources
Checked on .
- React: DOM components and attributes (className, htmlFor, style object)
- React: Responding to events (camelCase handler names, functions not strings)
- React: Writing markup with JSX (curly braces, single root)
- React: <input> (defaultValue and defaultChecked for uncontrolled inputs)
- Babel: @babel/preset-react 7.26 (used to compile the test output)
- WHATWG HTML: parsing of foreign (SVG) attributes
Frequently Asked Questions
Built by Derek Giordano · Part of Ultimate Design Tools