HTML to JSX Converter

Convert HTML to JSX in your browser — fixing the common React gotchas like class and inline styles. A fast regex first pass, not a full converter.

Developer Tools Free No upload Instant

Loading HTML to JSX Converter…

Your browser is preparing the tool. It runs 100% locally.

Quick Answer

Paste HTML and the tool rewrites the differences React needs: class becomes className, for becomes htmlFor, HTML comments become JSX comments, and an inline style string becomes a camelCased style object. It is a fast first pass for moving markup into a component. It is regex-based, so it does not self-close void elements or rename every attribute — review the result. It runs entirely in your browser; nothing is uploaded.

What the HTML to JSX Converter Does

This tool takes a block of HTML and applies the most common transformations needed to use it as JSX in a React component. It handles the renames and rewrites that would otherwise cause errors or warnings when you paste raw HTML into JSX.

It is the quick way to start converting a markup snippet — a template, an icon, a chunk of a page — into a component, doing the repetitive find-and-replace for you so you can focus on the parts that need judgement.

How It Works

The tool runs a set of regular expressions over your HTML. It renames the class attribute to className and for to htmlFor, turns HTML comments into JSX comment expressions, and converts an inline style string into a JavaScript object with camelCased property names, which is what JSX expects.

Because it works by pattern-matching rather than parsing the markup into a tree, it is fast and dependency-free. It also means it only changes the specific things its patterns target, and it cannot reason about the structure the way a full converter would.

Data source & conversion logic

  1. Rename class and for. Change the class attribute to className and for to htmlFor, the JSX equivalents.
  2. Convert comments. Turn HTML comments into JSX comment expressions inside braces.
  3. Rewrite inline styles. Turn a style string into a JavaScript object with camelCased property names.
  4. Return the JSX. Output the converted markup, ready to paste and refine in a component.

What it converts

class= → className= for= → htmlFor= HTML comment → JSX comment in braces inline style string → camelCased style object
Worked example
<div class="box" style="margin-top: 10px"><!-- hi --></div> → <div className="box" style={{marginTop: '10px'}}>{/* hi */}</div>

It fixes the common gotchas, but it is a regex pass: it does not self-close void elements (a br stays unclosed, which is invalid JSX) and renames only class and for, not the dozens of other camelCase attributes. Review the result.

Privacy

Your HTML never leaves your device. The conversion runs in your browser with no network request, so nothing is uploaded.

Because the work is local, you can convert proprietary templates or internal markup without it being stored or sent anywhere.

Nothing persists between sessions — close the tab and the input and output are gone.

Standards & references

  • JSX attribute naming — JSX uses camelCase for many attributes: className for class (a reserved word in JavaScript), htmlFor for for, onClick for onclick, and so on. This tool renames class and for; the others may need doing by hand.
  • Style as an object — In JSX the style attribute takes a JavaScript object with camelCased properties (fontSize, not font-size), not a CSS string. The tool performs this conversion for an inline style.
  • Self-closing tags — JSX requires every tag to be closed, including void elements like br and img, which must be written self-closed. This regex pass does not add the self-closing slash, so those need fixing manually.

Accuracy & Limitations

For the common cases it targets — class, for, comments and inline styles — the conversion is reliable and saves the repetitive edits that catch people out when pasting HTML into JSX.

It does not self-close void elements. Tags like br, img and input are valid in HTML without a closing slash, but JSX requires them self-closed. The tool leaves them as they are, so you must add the slash yourself or JSX will not compile.

It renames only class and for. JSX has dozens of other attribute differences — onclick to onClick, tabindex to tabIndex, and the many SVG attributes like stroke-width to strokeWidth — which this regex pass does not handle. Convert those by hand.

The style conversion is pattern-based, so an inline style whose value contains a colon (such as a url) or unusual syntax can be converted incorrectly. Check any complex inline styles in the output, and treat the result as a first pass to review.

Real-World Use Cases

Starting a component

Convert a markup snippet into JSX to drop into a React component.

Fixing the common gotchas

Rename class and for and rewrite inline styles automatically.

Migrating templates

Make a first pass over HTML templates moving to React.

Learning JSX differences

See how HTML attributes map to their JSX equivalents.

When to use it — and when not to

Good for

  • A first pass converting HTML to JSX
  • Renaming class and for automatically
  • Rewriting an inline style to an object
  • Learning the HTML-to-JSX differences

Not the best choice for

  • A complete, compile-ready conversion
  • Self-closing void elements automatically
  • Renaming every camelCase attribute
  • SVG-heavy or complex attribute markup

For a thorough conversion, use a parser-based HTML-to-JSX tool or your editor's converter, then compile to catch what remains. This regex pass handles the common gotchas; finish the void elements and other attribute renames by hand.

Frequently Asked Questions

What does it convert?
The common HTML-to-JSX differences: class becomes className, for becomes htmlFor, HTML comments become JSX comments, and an inline style string becomes a camelCased style object. Those are the changes that most often trip people up.
Does it self-close void elements?
No. Tags like br and img are valid unclosed in HTML, but JSX requires them self-closed. The tool does not add the slash, so you must close them yourself or JSX will not compile.
Does it rename every attribute?
No, only class and for. JSX has many other camelCase attributes — onclick to onClick, tabindex to tabIndex, and SVG attributes like stroke-width to strokeWidth — that this regex pass does not convert. Handle those by hand.
How does the style conversion work?
It turns an inline style string into a JavaScript object, camelCasing each property (margin-top becomes marginTop) and quoting the values, since JSX expects an object rather than a CSS string.
Is it a full parser?
No. It uses regular expressions to target specific patterns, not a parse of the markup into a tree. That makes it fast but limited to the cases its patterns cover, so review the output.
Why is class a problem in JSX?
Because class is a reserved word in JavaScript, and JSX compiles to JavaScript. React uses className instead, which is why the conversion is needed when moving HTML into a component.
Can a complex inline style break?
It can. A style value containing a colon (such as a url) or unusual syntax may convert incorrectly, because the tool splits on colons and semicolons. Check complex inline styles in the result.
Is my HTML uploaded anywhere?
No. The conversion runs entirely in your browser. Nothing is sent to a server, so private markup stays on your device.
Will the output compile as-is?
Often it needs a little cleanup — self-closing void elements and any remaining attribute renames. Treat it as a first pass, then compile to surface anything left to fix.
Does it handle data attributes?
Data attributes like data-id are valid in JSX as written, so they need no conversion. The tool leaves them alone, which is correct.
What about event handlers like onclick?
JSX uses camelCase event names (onClick) and a function rather than a string. This tool does not convert onclick, so rename event handlers and wire up functions by hand.
Can it convert JSX back to HTML?
No, it goes one way, HTML to JSX. To go the other direction you would reverse the renames and turn style objects back into strings, which a JSX-to-HTML tool does.

References

Rewrites the common HTML-to-JSX differences (class, for, comments, inline style) with regex; honest that it does not self-close void elements or rename every attribute, so review the output.

PopularHot

JSON Formatter

JSON Formatter for developers — instant, offline-style and privacy-safe.

DeveloperOpen Tool
Popular

JSON Validator

JSON Validator for developers — instant, offline-style and privacy-safe.

DeveloperOpen Tool
Popular

Base64 Encoder

Base64 Encoder for developers — instant, offline-style and privacy-safe.

DeveloperOpen Tool
Popular

Hash Generator

Fast, free Hash Generator that runs entirely client-side in your browser.

DeveloperOpen Tool
Popular

UUID Generator

Fast, free UUID Generator that runs entirely client-side in your browser.

DeveloperOpen Tool
Trending

CSS Minifier

Fast, free CSS Minifier that runs entirely client-side in your browser.

DeveloperOpen Tool

Ready to try the HTML to JSX Converter?

It is free, private and runs entirely in your browser — no sign-up, no uploads, no limits.