← All Tools

HTML to JSX Converter🔒 100% local

Convert HTML to JSX syntax. Handles class->className, for->htmlFor, event handlers, and style objects.

HTML Input

Related Tools

HTML BeautifierHTML EncoderHTML Decoder

Rewrites an HTML fragment into the shape React wants to see: class becomes className, for becomes htmlFor, tabindex becomes tabIndex, lower-case event attributes such as onclick are camel-cased, a style="..." string is turned into a {{...}} object, boolean attributes lose their ="true", and a tag already written with /> gains a space before the slash. Fragments are transformed by a pipeline of regular expressions in this tab, so there is no upload to a conversion service and no build step involved.

How to use it

  1. Paste an HTML fragment; the box starts with <div class="container"><span id="hello">Hello World</span></div>.
  2. Press Convert to JSX.
  3. Copy the JSX Output into your component, then fix the parts a regex cannot handle.

Worked example

<div class="container"><span id="hello">Hello World</span></div>becomes<div className="container"><span id="hello">Hello World</span></div>

Only the class attribute changed - id and the element structure were already valid JSX.

<a href="/x" style="color: red; font-size: 12px" onclick="go()">Hi</a>becomes<a href="/x" style={{color: 'red', fontSize: '12px'}} onClick="go()">Hi</a>

The style string became a camel-cased object and onclick became onClick, but the value is still the string "go()" - React will not call that.

<input type="text" disabled="true" readonly>becomes<input type="text" disabled readonly>

The boolean-attribute rule drops ="true" and leaves the bare attribute name.

When to use it

What it does not do