HTML to JSX converter

Convert HTML to JSX

Paste any HTML and get valid JSX: className, style objects, closed tags and camelCase attributes, ready to drop into a React component.

Output

HTML

JSX

<div className="pricing-card" style={{ borderRadius: "12px", padding: "24px" }}>
  {/* Plan header */}
  <h3 className="title">Pro plan</h3>
  <p className="price"><strong>$29</strong> per month, billed yearly</p>
  <label htmlFor="seats">Seats</label>
  <input id="seats" type="number" defaultValue="3" min="1" tabIndex="0" />
  <ul>
    <li>Unlimited projects</li>
    <li>Priority support</li>
  </ul>
  <button className="btn btn-primary" onClick={() => { startTrial(); }} disabled>
    Start free trial
  </button>
  <svg viewBox="0 0 24 24" width="16" height="16">
    <path strokeWidth="2" strokeLinecap="round" d="M5 12h14" />
  </svg>
</div>
  • Turned an inline event handler into an arrow function. Check the code it calls exists in your component.
  • Used defaultValue and defaultChecked for form fields, so they keep their starting values without onChange handlers.
  • Free, no sign-up
  • Runs in your browser
  • Your code never leaves your device

How to use it

How to use the HTML to JSX tool

Free, with no sign-up. Everything happens in your browser.

  1. 01

    Paste your HTML

    A snippet, a component from a UI kit or a whole page. Full documents work too: the converter takes what's inside <body>.

  2. 02

    Choose the output

    Plain JSX to drop into existing code, or a named React component that's ready to save as its own file.

  3. 03

    Copy or download

    The JSX updates as you type. Check the notes under it for anything worth a second look, then copy it or save the .jsx file.

Guide

What changes between HTML and JSX

JSX looks like HTML but compiles to JavaScript, so a few attributes, inline styles and some text need writing differently. These are the changes the converter makes for you.

class becomes className, for becomes htmlFor

class and for are reserved words in JavaScript, so React uses className and htmlFor. Attributes made of two words also switch to camelCase: tabindex becomes tabIndex, maxlength becomes maxLength and readonly becomes readOnly.

data-* and aria-* attributes are the exception. They keep their hyphens, exactly as in HTML.

HTML
<label class="field" for="email">Email</label>
<input id="email" tabindex="1" readonly>
JSX
<label className="field" htmlFor="email">Email</label>
<input id="email" tabIndex="1" readOnly />

Every tag has to close

HTML lets void elements like <img>, <br> and <input> stand open, and browsers quietly close a <li> or <p> you forgot. JSX is stricter: each element closes, either with an end tag or as self-closing with />.

The converter adds the missing slashes and end tags, and turns empty elements into the shorter self-closing form.

HTML
<ul>
  <li>One
  <li>Two
</ul>
<img src="logo.svg" alt="Logo">
JSX
<ul>
  <li>One</li>
  <li>Two</li>
</ul>
<img src="logo.svg" alt="Logo" />

Inline styles become objects

In JSX the style attribute takes a JavaScript object, not a string. CSS property names become camelCase keys, values become strings, and unitless numbers such as opacity or z-index become plain numbers.

Vendor prefixes follow React's rules (-webkit-transition becomes WebkitTransition) and CSS custom properties keep their names as quoted keys. React can't express !important, so it's dropped, and the notes tell you when that happens.

HTML
<div style="margin-top: 8px; z-index: 10; --gap: 4px">
JSX
<div style={{ marginTop: "8px", zIndex: 10, "--gap": "4px" }}>

Events, form fields and text

Inline handlers like onclick="save()" become camelCase props that take a function: onClick={() => { save(); }}. Check the function exists in your component, or move the logic into one.

Form fields keep their starting values without becoming controlled inputs: value becomes defaultValue, checked becomes defaultChecked, and a selected <option> becomes the <select>'s defaultValue. This avoids React's warning about a value without an onChange handler.

In text, curly braces and > would be read as code, so they're escaped. HTML comments turn into {/* JSX comments */}, and <pre> blocks keep every space and line break.

SVG inside your HTML

Icons pasted inline get their SVG attributes renamed too: stroke-width becomes strokeWidth, fill-rule becomes fillRule and xlink:href becomes xlinkHref, while viewBox keeps its capital B. For a reusable icon component with size and color props, use the SVG to React converter instead.

What it handles

Built for real-world code

The details that usually need fixing by hand, done for you.

  • Forgiving with real-world HTML

    Unclosed list items, paragraphs and table cells, stray end tags and unquoted attributes are all fixed the way a browser would read them.

  • Readable output

    Indented two spaces, short elements kept on one line, and long tags wrapped with one attribute per line.

  • Spaces that survive

    Where JSX would swallow a space between words and links, the converter adds {" "} so the text reads the same as in the browser.

  • Private by design

    The conversion runs in your browser. Your HTML isn't uploaded, stored or logged anywhere.

Screenshot to Code

Have a design instead of HTML?

Upload a screenshot of any page or mockup and get a complete React and Tailwind version, split into components, with a live preview you can refine by chat.

FAQ

Questions about HTML to JSX

Something else on your mind? Send us a message.

Yes. It's free with no sign-up and no limits, and it runs entirely in your browser.

More free tools

Keep going

More converters for HTML, React and Tailwind.