Toolvist

HTML to JSX Converter

Convert HTML to JSX for React — class becomes className, attributes are camelCased and tags self-close. Free HTML to JSX converter, instant output.

Paste any HTML fragment or full document body.

Free Online HTML to JSX Converter

The HTML to JSX Converter rewrites plain HTML into valid React JSX. It renames attributes (class becomes className, for becomes htmlFor), self-closes void elements, converts inline style strings into style objects, and fixes a few other HTML-only quirks.

The related syntax converters are the HTML to Pug Converter and the CSS to Tailwind Converter, and the attributes it transforms are formatted first by the HTML Formatter & Beautifier. For the data behind a component, the JSON to CSV Converter is the bridge.

How to use the HTML to JSX

  1. 1 Paste your HTML.
  2. 2 Convert. Attribute names are rewritten for JSX and self-closing tags are normalised.
  3. 3 Check the reported warnings for attributes with no direct equivalent.
  4. 4 Copy the JSX into your component.

Where the conversion stops

The conversion handles syntax, not semantics. It cannot know that an `onclick` string should become a function, or that a `<label>` with a `for` attribute should be associated with a component rather than an id string. Those are decisions about the target framework.

It is most useful when migrating a static template into components, where the markup is largely presentational and the interactive parts need rewriting anyway. Convert the structural markup, then handle the behaviour deliberately rather than expecting the converter to translate it.

  • `class` to `className`, `for` to `htmlFor`.
  • Hyphenated and event attributes become camelCase.
  • Inline `style` strings become objects.
  • Inline event handler strings should be rewritten, not converted.

Why convert HTML to JSX?

JSX looks like HTML but is stricter. React rejects reserved words like class and for, requires camelCase for most attributes, and needs self-closing void tags. This tool handles those differences automatically so you can paste existing markup straight into a component.

Frequently asked questions

Which attributes get renamed?

The ones that collide with reserved words or differ in JSX. `class` becomes `className`, `for` becomes `htmlFor`, and attributes containing hyphens become camelCase, so `tabindex` becomes `tabIndex`. Event handlers change to camelCase too, and data and aria attributes keep their hyphens as written.

Why does my inline style break?

Because JSX expects a style as an object rather than a string. A `style` attribute written in CSS syntax has to be converted to an object with camelCased properties and quoted string values. The conversion does this, but a value that relied on CSS syntax such as a shorthand with a slash cannot be represented directly.

What about comments and event attributes?

HTML comments become JSX comments, which need braces around them. Inline event attributes such as `onclick` should not be carried across at all — in React those are functions passed as props, not strings, so a converted string handler is a defect rather than a fix.

Related Developer Tools

Browse all Developer Tools →

You might also need

Tools from other categories that people pair with the HTML to JSX:

Browse the full tool directory →