HTML to JSX Converter

Paste HTML and get valid JSX for React components, with attributes, styles, comments and SVG converted for you.

FreeNo sign-upPrivate — runs in your browser
0Attributes renamed
0Styles converted
0Elements

How to use the HTML to JSX Converter

  1. Paste your HTMLPaste markup from a template, a design tool or an old page. Only what is inside the body is converted.
  2. Check the JSXclass becomes className, for becomes htmlFor, inline styles become objects, void tags are self-closed, comments become {/* */} and SVG attributes are camelCased.
  3. Copy it into ReactKeep “Wrap in a component” to get a ready-to-use function component, then copy the result. Inline onclick handlers are turned into empty arrow functions for you to fill in.

Example

<div class="card" style="padding: 16px"> becomes <div className="card" style={{ padding: '16px' }}>.

stroke-width="2" inside an SVG becomes strokeWidth="2", and <input required> becomes <input required />. Two top-level elements are wrapped in a fragment <>…</>.

Frequently asked questions

Why does React need className instead of class?

JSX is JavaScript, where class is a reserved word, so React uses className. In the same way, for on labels becomes htmlFor.

What happens to inline event handlers like onclick?

React handlers are functions, not strings, so onclick="signup()" becomes onClick={() => { /* signup() */ }}. Replace the comment with your real function call.

Why did value become defaultValue?

In React, value on an input makes it a controlled field that needs state. defaultValue keeps the HTML behaviour of an editable starting value. Change it back to value if you add state.

Popular posts from this blog

Character Counter

Speech to Text Online

Keyboard Tester