HTML to JSX

Convert HTML to React JSX: class to className, inline styles to objects, self-closing tags and comments. Optionally wrap it in a component.

About this tool

Convert HTML to React JSX. Attributes are renamed (class → className, for → htmlFor), inline styles become objects, void tags self-close and comments become JSX comments.

How to use

  1. Paste HTML.
  2. Optionally enable Wrap in component.
  3. Copy the JSX into your React code.

Frequently asked questions

What about multiple root elements?

They are wrapped in a fragment <>…</> so the result is valid JSX.

Are event handlers converted?

onclick becomes onClick, but the value stays a string. Replace it with a function in your component.

How are curly braces in text handled?

They are escaped as {'{'} and {'}'} so JSX does not treat them as expressions.

Related tools