Rankato

Free HTML to JSX Converter

Paste HTML → get valid JSX. Attribute renames, camelCased events, style objects, self-closed void tags, and optional component wrapping — all in your browser.

HTML
JSX
Your JSX will appear here.

Converted in your browser · never sent to any server

The HTML to JSX Converter takes any snippet of HTML and turns it into valid JSX you can paste directly into a React component. It renames reserved attributes (classclassName, forhtmlFor), converts kebab-case DOM attributes to camelCase, self-closes void elements (<br>, <img>, <input>), parses inline style strings into React style objects, converts HTML comments to JSX comments, and strips inline event handlers so nothing silently breaks at runtime. Optionally wraps output in a fragment or a full React function component.

What does an HTML to JSX converter do?

JSX looks almost identical to HTML, but not quite: class is a reserved word in JavaScript, so React renamed it to className. for becomes htmlFor. Every kebab-case DOM property (tab-index, stroke-width, cell-padding) is camelCased in React. Inline style attributes take a JavaScript object, not a semicolon-separated string. Void tags like <br> and <img> must be self-closed. Paste any HTML snippet — a marketing landing page, a design-system component, a form, an SVG icon — and this tool applies every one of those rules for you in a single pass.

How the converter works

  1. Your HTML is parsed with the browser's native DOMParser, so tag nesting and attribute quoting behave exactly like they would in a real page.
  2. The DOM tree is walked recursively. For each element the tool remaps reserved attribute names, camelCases kebab-case and SVG attributes, and preserves data-* and aria-* attributes verbatim.
  3. Inline style values are split on ;, each property is camelCased, and numeric values are kept unquoted so you can drop the result into a React style={{ … }} prop.
  4. Void elements are emitted with a trailing /, HTML comments become {/* … */}, and inline event handlers like onclick="…" are stripped with a warning so you don't ship broken code.
  5. Optionally, the output is wrapped in a JSX fragment or a full export function Component() { return (…); } scaffold.

Which HTML attributes get renamed?

The most common renames are class → className and for → htmlFor. Beyond those, React expects camelCase for every multi-word DOM property: tabindex → tabIndex, readonly → readOnly, maxlength → maxLength, cellpadding → cellPadding, colspan → colSpan, rowspan → rowSpan, usemap → useMap, contenteditable → contentEditable, crossorigin → crossOrigin, autocomplete → autoComplete, autofocus → autoFocus, spellcheck → spellCheck, srcset → srcSet, enctype → encType, formnovalidate → formNoValidate, referrerpolicy → referrerPolicy, and many more. SVG attributes follow the same rule: stroke-width → strokeWidth, fill-rule → fillRule, clip-path → clipPath. data-* and aria-* attributes stay as-is because React accepts them verbatim.

Inline styles: from string to object

HTML lets you write style="padding: 16px; background-color: #f5f5f5;". In JSX that same style has to be a JavaScript object with camelCase keys: style={{ padding: '16px', backgroundColor: '#f5f5f5' }}. The converter handles this automatically: it splits the declaration list, camelCases each property (skipping CSS custom properties like --brand-color, which stay quoted), and keeps bare numeric values unquoted so React can apply them as pixel values. Turn the toggle off if you'd rather keep the raw string and convert manually later.

Wrap in a fragment or a full component

By default, the output is a bare JSX tree. If your snippet has multiple sibling elements, React requires them to be wrapped in a fragment or a single parent — flip the Wrap toggle to <> fragment and the tool will do it for you. Choose React component to emit a complete export function MyComponent() { return (…); } scaffold you can paste straight into a new .tsx file. The component name field lets you customise the identifier; the first character is auto-capitalised because React component names must start with a capital letter.

Tool FAQs

Everything you need to know about using HTML to JSX Converter.

Why does React use className instead of class?+

class is a reserved word in JavaScript (it's used to declare classes with the class keyword). Because JSX compiles down to JavaScript function calls, using class as a property name would conflict with the language. React chose className — the same name the DOM API uses (element.className) — to avoid that clash. Similarly, for becomes htmlFor because for is a loop keyword.

Does this tool handle SVG attributes correctly?+

Yes. SVG uses a lot of hyphenated attributes (stroke-width, fill-rule, clip-path, text-anchor) that must be camelCased in JSX. The converter recognises the full set of standard SVG attributes and converts them correctly. Namespaced attributes like xlink:href become xlinkHref as React expects.

What happens to inline event handlers like onclick?+

Inline event handlers (onclick, onchange, onsubmit, etc.) are stripped from the output and reported in the warnings panel. React attaches event listeners through props like onClick={handleClick} pointing at a function — you can't paste a string of JavaScript into a JSX attribute. After conversion, wire up event handlers manually in your component.

Are inline styles converted to objects?+

Yes, if the toggle is on (it's on by default). A string like style="padding: 16px; color: red;" becomes style={{ padding: '16px', color: 'red' }}. CSS property names are camelCased, but CSS custom properties (variables that start with --) are preserved as quoted string keys because their names are case-sensitive. If you'd rather keep the raw style string and convert it yourself later, flip the toggle off.

Why do void elements like <br> need to be self-closed in JSX?+

JSX is XML-flavoured, and XML requires every open tag to be explicitly closed. HTML allows <br>, <img>, <input>, and other void elements to omit the closing tag entirely, but JSX won't parse without a self-closing slash: <br />. The converter handles this for every void element (br, hr, img, input, link, meta, source, area, base, col, embed, param, track, wbr).

Can I paste a full HTML page or just snippets?+

Snippets work best. If you paste a full HTML document (<!DOCTYPE>, <html>, <head>, <body>), the parser will still handle it, but you rarely want <html> or <head> inside a React component. Paste the fragment you want to convert — a form, a card, an SVG icon, a nav — and let the converter focus on that.

Does this tool send my HTML to a server?+

No. Conversion runs entirely in your browser using the built-in DOMParser. You can open your browser's Network tab and confirm zero requests fire when you paste. This makes it safe to convert unreleased design work, internal admin UIs, or any HTML you'd rather not paste into a random online tool.