Toolspark

HTML to JSX Converter

Convert HTML to JSX for React. Transforms attributes, styles, comments, and self-closing tags.

Share:𝕏fin↗
✓ class → className✓ for → htmlFor✓ style string → style object✓ HTML comments → JSX comments✓ Self-closing tags fixed✓ Boolean attributes cleaned✓ Event handlers camelCased✓ HTML attributes → JSX attributes
<div className="container">
  <label htmlFor="name">Name:</label>
  <input type="text" id="name" className="form-control" readOnly tabIndex="1" autoFocus />
  <img src="avatar.png" className="avatar" />
  <br />
  <hr />
  <div style={{{ backgroundColor: '#f0f0f0', padding: 20, marginTop: 10 }}}>
    <p className="text" contentEditable="true">Hello World</p>
    <button className="btn" disabled onClick="handleClick()">Submit</button>
  </div>
  {/* This is a comment */}
  <select className="select" multiple>
    <option value="1" selected>One</option>
  </select>
</div>

Conversions Applied

class="..."→className="..."
for="..."→htmlFor="..."
style="color: red"→style={{ color: 'red' }}
tabindex="1"→tabIndex="1"
<!-- comment -->→{/* comment */}
<img src="...">→<img src="..." />
<br>→<br />
<input ...>→<input ... />
disabled="disabled"→disabled
onclick="..."→onClick="..."
readonly→readOnly
contenteditable→contentEditable

Frequently Asked Questions

Related Tools