Skip to content
migration.tools
HTML to JSX

HTML to JSX converter

Migrating server-rendered templates, a static site or a design export to React? Paste the markup and get JSX that compiles — the mechanical renames done, so you can spend your time on the parts that need thought.

Options

HTML

JSX

The result appears here as soon as there is input.

Processed on this device. Nothing you paste or drop is uploaded.

How to use it

  1. 1Paste your HTML or drop a file onto the input panel.
  2. 2Adjust the options — the result updates as you type.
  3. 3Copy the JSX or download it. Drop several files to convert a batch into one ZIP.

What is rewritten

class becomes className, for becomes htmlFor, and attributes such as tabindex, maxlength and colspan are camelCased. SVG attributes are handled too: stroke-width becomes strokeWidth, xlink:href becomes xlinkHref. data-* and aria-* attributes are left alone, as React expects.

Inline style strings become style objects with camelCased properties. Void elements such as <img>, <input> and <br> are self-closed. Comments become JSX comments, and literal braces in text are escaped.

Inline event handlers can't be translated mechanically — onclick="track('checkout')" refers to a global function — so each becomes an empty arrow function with the original code in a comment.

Questions

Does it work for SVG icons?

Yes. Paste the SVG and you get a component with camelCased attributes. Replace hard-coded fill and stroke colours with currentColor if you want the icon to inherit text colour.

What about several root elements?

They are wrapped in a fragment (<>…</>), since a component must return a single root.