Skip to content

Menu

HTML to JSX

Convert HTML to JSX syntax

Runs entirely in your browserConvertersFree, no sign-up
Loading tool

01What is HTML to JSX?

Copy a chunk of markup from a template or an old page into a React component and the compiler starts complaining. class should be className, the <br> needs closing, and the style attribute must be an object. This converter handles that mechanical cleanup so you can focus on the parts that need thought. It works with a short series of regular-expression passes, run in a fixed order. First, HTML comments become JSX comments in {/* */} form, because JSX has no way to output a real HTML comment. Next, void elements get self-closed: br, hr, img, input, meta, link, area, base, col, embed, source, track and wbr. Tags that already end in /> are left alone. Then attribute names inside each tag are renamed to the spelling React's DOM docs list. class and for become className and htmlFor. Others include tabIndex, readOnly, maxLength, colSpan, rowSpan, crossOrigin, encType, charSet, httpEquiv, autoComplete, autoFocus and autoPlay. Seventeen inline event attributes are camelCased too, so onclick becomes onClick and ondblclick becomes onDoubleClick. data- and aria- attributes stay as they are, which is what React expects. Inline styles get the most work. Property names are camelCased, and vendor prefixes like -webkit-transform become WebkitTransform. Pixel values turn into plain numbers, since React adds px back for you. Unitless numbers stay numeric and everything else is quoted. A real run of style="-webkit-transform: scale(2); line-height: 1.5; z-index: 10; width: 50%" gives {{WebkitTransform: "scale(2)", lineHeight: 1.5, zIndex: 10, width: "50%"}}. Some things are left for you. Event handler values stay as strings, so onClick="go()" still needs rewriting as onClick={go}. Dashed SVG attributes such as stroke-width and fill-rule are not renamed. The tool does not wrap sibling elements in a fragment, and it does not validate the HTML. HTML email deserves a special mention. Outlook conditional comments like <!--[if mso]> become JSX comments, so markup meant only for Outlook ends up commented out. When the input has any, a warning shows how many were found. The JSX Output panel refreshes on each edit. Your markup stays in the browser tab, so a client's unreleased page never leaves your machine.

React and Next.js developers use it when they copy HTML from a template, a design hand-off or a legacy page and need valid JSX attributes and style objects fast. The tool runs entirely in your browser, so your data never leaves your device.

02How to use HTML to JSX

  1. Paste your markup into HTML Input, or load Form Elements, Styled Component or Media & Comments.
  2. Review the converted code in JSX Output. It updates as you type.
  3. Read any warning about Outlook conditional comments before you use the result in an email template.
  4. Click Copy JSX and paste the result into your component's return statement, or click Reset to start again.

03Worked examples

Input: <label for="email" class="lbl">Email</label>
Result: <label htmlFor="email" className="lbl">Email</label>
The two renames everyone hits first.
Input: <img src="a.png" alt="A"><br>
Result: <img src="a.png" alt="A" /><br />
JSX requires void elements to be self-closed.
Input: <div style="-webkit-transform: scale(2); line-height: 1.5; z-index: 10; width: 50%">x</div>
Result: <div style={{WebkitTransform: "scale(2)", lineHeight: 1.5, zIndex: 10, width: "50%"}}>x</div>
Vendor prefixes are capitalised, unitless numbers stay numeric and percentages stay quoted.
Input: <input type="text" maxlength="40" readonly autofocus>
Result: <input type="text" maxLength="40" readOnly autoFocus />
Attribute names are camelCased and the void tag is closed. The value "40" stays a string, which React accepts.
Input: <button onclick="go()" tabindex="0">Go</button>
Result: <button onClick="go()" tabIndex="0">Go</button>
Only the attribute name changes. You still need to rewrite the handler as onClick={go}.
Input: <!--[if mso]><table><tr><td><![endif]-->
Result: {/*[if mso]><table><tr><td><![endif]*/}
The Outlook-only table is now inside a JSX comment and will not render. The tool shows a warning with the count.

04Common use cases

  • Pasting a Bootstrap or Tailwind UI snippet into a Next.js component without hand-fixing every class attribute
  • Turning a static landing-page section exported from a site builder into JSX
  • Moving a login form with for, maxlength and readonly attributes into a React Hook Form component
  • Converting markup with inline styles from an old CMS template into style objects
  • Checking which parts of an HTML email template rely on Outlook conditional comments before porting it to React Email
  • Cleaning up embed snippets with self-closing tags like img, source and track

05Tips

  • Handler strings are kept as they were. onClick="handleSubmit()" will fail in React until you change it to onClick={handleSubmit}.
  • JSX needs one root element. Wrap multiple top-level siblings in a fragment (<>...</>) yourself.
  • Dashed SVG attributes such as stroke-width and fill-rule pass through unchanged. Rename them to strokeWidth and fillRule.
  • Percentages, ems and other units stay as quoted strings. Only px values and bare numbers become numbers.
  • For email templates, rebuild Outlook-only blocks with your email framework's components rather than relying on the converted comments.

06Related concepts

JSX, React attributes, className, Inline style objects, Self-closing tags.

Frequently Asked Questions

What is HTML to JSX?

HTML to JSX is a free, browser-based developer tool on AIDToolStack. Convert HTML to JSX syntax It requires no installation or sign-up and works entirely in your browser.

Is HTML to JSX free to use?

Yes. No sign-up, no fees and no usage cap.

Does HTML to JSX store my data?

No. It runs in your browser; nothing is uploaded.

Cheat sheet

Reviews and commentsShow

Reviews

Sign in to leave a review.

Loading reviews…

Comments

Sign in to leave a comment.

Loading comments…

What changed in AI dev tools, once a month

Renames, shutdowns, pricing changes and new MCP setups, each with a source.

Subscribe