Convert HTML markup into valid JSX (class->className, style objects, self-closing).
The HTML to JSX converter rewrites plain HTML markup so it can be pasted into a React component. It renames attributes such as class and for, turns inline style strings into style objects, and closes void tags. It is meant for developers moving static templates, snippets from documentation or exported markup into React code.
JSX is the XML-like syntax React uses to describe UI inside JavaScript. It looks like HTML but follows JavaScript rules. Attribute names use the DOM property names, so class becomes className, for becomes htmlFor and tabindex becomes tabIndex. The style attribute is not a string but an object with camelCase keys, such as style={{ fontSize: '12px' }}. Every element must be closed, so void elements like input, img and br are written with a trailing slash. Event handlers are camelCase functions rather than strings, and curly braces in text are special because they open a JavaScript expression. Converting by hand is tedious and easy to get subtly wrong, so a converter that applies these rules consistently saves time. The result still needs a quick review before you ship it.
It maps the common ones (class, for, tabindex, readonly, maxlength, colspan, charset, srcset and many others) to their React names and keeps data-* and aria-* attributes as they are. Unusual attributes are passed through, so scan the output for anything React warns about.
The content of a style or script element is emitted as a template literal inside curly braces so that JSX can parse it. The tags themselves are kept.
The tool indents with two spaces and keeps one element per line, but it does not wrap long attribute lists. Run your formatter afterwards.
Ampersands and angle brackets in text are escaped as entities, and literal { and } are written as {'{'} and {'}'} so JSX does not treat them as expressions.
No. The conversion runs in the page and the input stays on your device.