T
THINKFORU
Submit Feedback

HTML to JSX/TSX Converter: React Code Generator

HTML to JSX/TSX Converter: React Code Generator

HTML to JSX / TSX Converter

Save on Google
// JSX appears here
Related Developer Tools
Tool NameExplanation
JSON to Go Struct ConverterGenerates idiomatic Go structs with json tags from any JSON payload.
JSON to TypeScript InterfaceGenerates typed TypeScript interfaces from any JSON payload.
TOML to JSON ConverterTransforms TOML config files into clean, formatted JSON.
Binary to Text ConverterDecodes binary (0s and 1s) into readable text and back.
Base64 Encode / DecodeEncodes text or files to Base64 and decodes Base64 strings instantly.

HTML vs JSX Attribute Translation & Event Handler Reference

HTML Attribute / SyntaxJSX EquivalentCategoryUsage Note
class="btn"className="btn"Attributeclass is a reserved word in JavaScript
for="email"htmlFor="email"Attributefor is a reserved loop keyword
tabindex="0"tabIndex={0}AttributecamelCase; numeric value as a number
readonlyreadOnlyAttributeBoolean attribute, camelCase
maxlength="20"maxLength={20}AttributeNumber in braces for TypeScript
minlength="3"minLength={3}AttributeNumber in braces for TypeScript
colspan="2"colSpan={2}AttributeTable cell
rowspan="2"rowSpan={2}AttributeTable cell
cellpadding="0"cellPadding="0"AttributeLegacy table attribute
cellspacing="0"cellSpacing="0"AttributeLegacy table attribute
contenteditablecontentEditableAttributeWarns when children exist; add suppressContentEditableWarning
spellcheck="false"spellCheck="false"AttributeTakes a string or boolean
autocomplete="off"autoComplete="off"AttributeForm fields
autofocusautoFocusAttributeFocuses on mount
autoplayautoPlayAttributeAudio and video
autocapitalize="none"autoCapitalize="none"AttributeMobile keyboards
enctype="multipart/form-data"encType="multipart/form-data"AttributeForm uploads
formaction="/save"formAction="/save"AttributeButton override; accepts a function in React 19
formnovalidateformNoValidateAttributeSubmit button override
novalidatenoValidateAttributeForm attribute
accept-charset="UTF-8"acceptCharset="UTF-8"AttributeHyphen becomes camelCase
http-equiv="refresh"httpEquiv="refresh"AttributeMeta tag
charset="utf-8"charSet="utf-8"AttributeMeta tag
srcset="a.png 2x"srcSet="a.png 2x"AttributeResponsive images
srcdoc="..."srcDoc="..."AttributeIframe inline document
srclang="en"srcLang="en"AttributeTrack element
usemap="#map"useMap="#map"AttributeImage maps
datetime="2026-10-27"dateTime="2026-10-27"Attributetime and del elements
hreflang="en"hrefLang="en"AttributeLinks
crossorigin="anonymous"crossOrigin="anonymous"AttributeScripts, images, links
referrerpolicy="no-referrer"referrerPolicy="no-referrer"AttributeLinks and images
allowfullscreenallowFullScreenAttributeIframes
playsinlineplaysInlineAttributeMobile video
itemprop="name"itemProp="name"AttributeMicrodata
itemscopeitemScopeAttributeMicrodata
itemtype="https://schema.org/Person"itemType="https://schema.org/Person"AttributeMicrodata
accesskey="s"accessKey="s"AttributeKeyboard shortcut
inputmode="numeric"inputMode="numeric"AttributeMobile keyboard hint
enterkeyhint="go"enterKeyHint="go"AttributeMobile keyboard hint
fetchpriority="high"fetchPriority="high"AttributeImages; React 19 or later
frameborder="0"frameBorder="0"AttributeIframes
nomodulenoModuleAttributeScript element
<input value="x"><input defaultValue="x" />Attributevalue alone makes the input controlled and read-only
<input checked><input defaultChecked />Attributechecked alone needs an onChange
<option selected><select defaultValue="b">AttributeReact warns on selected; set defaultValue on select
disabled=""disabledAttributeEmpty boolean attributes become bare
data-id="7"data-id="7"Attributedata-* attributes stay hyphenated
aria-label="Close"aria-label="Close"Attributearia-* attributes stay hyphenated
stroke-width="2"strokeWidth="2"AttributeSVG attributes become camelCase
fill-rule="evenodd"fillRule="evenodd"AttributeSVG
clip-path="url(#c)"clipPath="url(#c)"AttributeSVG
stroke-linecap="round"strokeLinecap="round"AttributeSVG
stroke-linejoin="round"strokeLinejoin="round"AttributeSVG
xlink:href="#a"xlinkHref="#a"AttributePrefer href in modern SVG
xmlns:xlink="..."xmlnsXlink="..."AttributeSVG root
xml:lang="en"xmlLang="en"AttributeNamespaced attribute
viewBox="0 0 24 24"viewBox="0 0 24 24"AttributeAlready camelCase, unchanged
onclick="go()"onClick={() => go()}Event HandlerString becomes an arrow function
ondblclickonDoubleClickEvent HandlerName differs from the DOM event
onchangeonChangeEvent HandlerFires on every keystroke for text inputs in React
oninputonInputEvent HandlerSame timing as onChange in React
onsubmitonSubmitEvent HandlerCall event.preventDefault() yourself
onresetonResetEvent HandlerForm reset
onfocusonFocusEvent HandlerBubbles in React, unlike DOM focus
onbluronBlurEvent HandlerBubbles in React, unlike DOM blur
onkeydownonKeyDownEvent HandlerUse event.key
onkeyuponKeyUpEvent HandlerUse event.key
onkeypressonKeyPressEvent HandlerDeprecated; prefer onKeyDown
onmousedownonMouseDownEvent HandlerMouse
onmouseuponMouseUpEvent HandlerMouse
onmousemoveonMouseMoveEvent HandlerMouse
onmouseoveronMouseOverEvent HandlerBubbles
onmouseoutonMouseOutEvent HandlerBubbles
onmouseenteronMouseEnterEvent HandlerDoes not bubble
onmouseleaveonMouseLeaveEvent HandlerDoes not bubble
oncontextmenuonContextMenuEvent HandlerRight click
onscrollonScrollEvent HandlerScrollable elements
onwheelonWheelEvent HandlerPassive by default
onloadonLoadEvent HandlerImages, iframes
onerroronErrorEvent HandlerImages, media
oncopy / oncut / onpasteonCopy / onCut / onPasteEvent HandlerClipboard events
ondrag / ondroponDrag / onDropEvent HandlerDrag and drop; also onDragStart, onDragOver
ontouchstartonTouchStartEvent HandlerTouch
onpointerdownonPointerDownEvent HandlerPointer events
onplay / onpauseonPlay / onPauseEvent HandlerMedia events
onanimationendonAnimationEndEvent HandlerCSS animations
ontransitionendonTransitionEndEvent HandlerCSS transitions
style="color:red"style={{ color: 'red' }}StyleString becomes an object
font-size:14pxfontSize: '14px'StyleProperty names become camelCase
background-color:#fffbackgroundColor: '#fff'StylecamelCase
z-index:10zIndex: 10StyleUnitless numbers stay numbers
opacity:0.5opacity: 0.5StyleUnitless number
-webkit-box-shadow:noneWebkitBoxShadow: 'none'StyleVendor prefix gets a capital letter
-ms-transform:nonemsTransform: 'none'Stylems prefix is lowercase
--brand:#06f'--brand': '#06f'StyleCustom properties are quoted keys
background:url(a.png)background: 'url(a.png)'StyleValues stay strings
color:red !importantcolor: 'red !important'StyleReact ignores !important in inline styles; use a CSS class instead
<br><br />Tag / SyntaxVoid elements must self-close
<img src="a.png"><img src="a.png" />Tag / SyntaxVoid element
<input type="text"><input type="text" />Tag / SyntaxVoid element
<hr><hr />Tag / SyntaxVoid element
<meta> / <link><meta /> / <link />Tag / SyntaxVoid elements
<!-- note -->{/* note */}Tag / SyntaxHTML comments are not valid in JSX
&nbsp;&nbsp;Tag / SyntaxEntities are valid in JSX text
{ or } in text{'{'} / {'}'}Tag / SyntaxBraces start expressions in JSX
two root elements<>...</>Tag / SyntaxWrap siblings in a Fragment
<script>code</script><script>{`code`}</script>Tag / SyntaxTemplate literal keeps the text intact
<style>a{}</style><style>{`a{}`}</style>Tag / SyntaxBraces would break otherwise
<textarea>text</textarea><textarea defaultValue="text" />Tag / SyntaxText children are not supported
<pre>a b</pre><pre>{"a b"}</pre>Tag / SyntaxExpression keeps whitespace exact
inline space between tags{' '}Tag / SyntaxJSX trims whitespace at line ends
<a href="#"><a href="#">Tag / SyntaxValid, but prefer a button or router Link

Technical Q&A / FAQ Matrix

Technical Developer QuestionExact React / JSX Solution & Code Snippet
How do I convert inline style to a React style object?style="color:red;font-size:14px" becomes style={{ color: 'red', fontSize: '14px' }}
Why does React say class is invalid?Use className: <div className="card"></div>
How do I keep HTML comments?Convert to a JSX comment: {/* comment */}
How do I return two sibling elements?Wrap them in a Fragment: return (<><h1>A</h1><p>B</p></>);
Why is my input read-only after conversion?value without onChange locks it. Use defaultValue for uncontrolled inputs: <input defaultValue="x" />
How do I insert raw HTML string?<div dangerouslySetInnerHTML={{ __html: html }} /> // sanitize first
How do I convert onclick="save()"?onClick={() => save()} or onClick={save}
Why do SVG attributes break?Hyphenated names become camelCase: stroke-width to strokeWidth, clip-path to clipPath
How do I preserve whitespace in pre?<pre>{"line 1\n line 2"}</pre>
Does the output work in Next.js?Yes. Paste into a component file; add 'use client' at the top if you use event handlers in the App Router.