HTML to JSX Converter
Convert HTML into valid JSX, with attributes renamed, inline styles turned into objects and void elements closed.
About this conversion
Attributes that were renamed
Import from File
Drag & drop a file here
or
Supports .txt, .csv, .log, .json and other text files
Conversion runs in your browser. The output is valid JSX markup, but it still needs wrapping in a component function, and anything dynamic in the original arrives as literal text.
What It Does
JSX looks like HTML and is not, and the differences are exactly the sort that produce silent failures rather than errors. Attribute names follow DOM properties rather than HTML, so class becomes className and for becomes htmlFor — both reserved words in JavaScript — along with a long tail of renames like tabindex to tabIndex. Every element must be closed, so void elements such as br and img gain a trailing slash. Inline styles stop being strings and become objects with camelCased keys. Comments change form entirely. This does all of that mechanically, which is most of the work in moving a template into React, and wraps multiple top-level elements in a fragment because a component has to return one thing.
When to Use It
- You are porting an existing HTML template or email into a React component.
- A designer supplied static markup and you need it as JSX without renaming every attribute by hand.
- You copied an element out of the browser inspector and want it in a component.
- An SVG icon needs to go inline in React, where every attribute name changes.
- You are migrating a server-rendered page piece by piece and want each fragment translated accurately.
Worked Examples
<div class="card"><label for="name">Name</label><input id="name" readonly></div>
The three renames everyone hits at once. class and for are reserved words in JavaScript so they become className and htmlFor, readonly becomes readOnly, and the input gains a closing slash because JSX has no void elements.
<p style="background-color: red; font-size: 14px">Hi</p>
A style string becomes an object with camelCased keys and double braces — the outer pair is the JSX expression, the inner is the object literal. Values stay strings, since React only auto-adds px for some properties.
<h1>Title</h1>
<!-- a note -->
<p>Body</p>
Two top-level siblings, so the output is wrapped in a fragment — a component must return one element. The comment becomes the JSX brace-and-comment form rather than being dropped.
Features
How to Use
1. Paste your HTML, or import a file. 2. The JSX appears immediately below. 3. Check the list of renamed attributes to see exactly what changed. 4. Copy the result into your component, wrapping it in a function and a return. 5. Replace any templating placeholders with real expressions.
Common Mistakes
- Leaving class and for as they are. Both are reserved words in JavaScript, so React ignores them and only warns in the console — the styling simply does not apply.
- Passing a style string. JSX expects an object with camelCased keys, and a string throws rather than failing quietly.
- Forgetting to close void elements. An unclosed br or img is a syntax error in JSX, not a style choice.
- Returning several top-level elements. A component must return one thing, so siblings need a fragment or a wrapper.
- Treating the output as a finished component. It is markup — it still needs a function around it, and anything dynamic in the original comes through as literal text.