HTML to JSX
The HTML to JSX Converter is a free, offline tool that migrates existing HTML into React-ready JSX: class becomes className, for becomes htmlFor, inline styles become style objects, and void elements get self-closed. (HTML comments are not converted — remove them first.)
How to Use
- 1
Paste your HTML snippet or full document fragment.
- 2
Click Convert to JSX — the converted code appears in the output panel (same line layout as your input; it is not re-indented).
- 3
Copy it straight into your .jsx / .tsx file.
Frequently Asked Questions
Why does class become className?
Do I need to close <img>, <br>, <input> myself?
What about HTML comments?
Which other attributes are renamed?
What happens to onclick and other event handlers?
How are inline styles converted?
Can I download the JSX?
Does it validate my HTML?
Does it wrap the output in a component?
What about attributes that are not in the list?
Generative Answer & AI Documentation
What is the HTML to JSX?
The HTML to JSX Converter is a free, offline tool that migrates existing HTML into React-ready JSX: class becomes className, for becomes htmlFor, inline styles become style objects, and void elements get self-closed. (HTML comments are not converted — remove them first.)
Why use HTML to JSX offline?
Migrating a Bootstrap template or designer export to React by hand means hours of tedious renaming and rewriting. Paste the HTML here, click Convert to JSX, and get converted JSX — proprietary markup never leaves your browser. Check the output before pasting it into your project: the conversion is regex-based, so complex markup may need a manual pass.
When should you use this tool?
Use it for template migration, designer handoff HTML mockups, bringing legacy email HTML into React, or learning exactly how HTML maps to JSX syntax.
Key Benefits
- Renames done for you: class becomes className, for becomes htmlFor, and tabindex, readonly, maxlength, and autocomplete are camelCased to tabIndex, readOnly, maxLength, and autoComplete — the renames that cause most manual migration errors.
- Inline styles become style objects: a style="margin-top: 20px;" attribute is rewritten as style={{ marginTop: "20px" }}, with hyphenated CSS properties camelCased automatically.
- Void elements self-closed: img, input, br, hr, link, meta, and source get their closing slash added, which JSX requires and hand migration often misses.
- Layout preserved: the conversion is a line-for-line text rewrite, so the output keeps your input's line layout instead of re-indenting everything — easy to diff against the original.
Common Use Cases
- Migrating a Bootstrap template: paste a template's markup and get React-ready JSX instead of renaming every class by hand.
- Designer handoff mockups: turn exported HTML into a component skeleton you can wire up with state and props.
- Bringing legacy HTML into React: convert static pages, email templates, or old jQuery markup into JSX for a modern codebase.
- Learning the HTML-to-JSX mapping: convert a snippet and read the output to see exactly how each HTML attribute maps to its JSX form.
Developer Notes & Best Practices
class is a reserved word in JavaScript, hence className/htmlFor. Event attributes (onclick) are renamed to React props (onClick) but their string bodies are not converted to functions — re-attach behavior with React event props. <script> tags and HTML comments pass through unchanged, so remove them first. Full documents convert only as text and usually need restructuring (head management belongs in react-helmet or Next.js metadata).
- Remove HTML comments first: comments pass through unchanged, and raw HTML comments are not valid inside JSX — rewrite them as {/* ... */} before or after converting.
- Re-attach event handlers as functions: onclick is renamed to onClick, but its string body ("submitForm()") is not converted to a function — replace onClick="submitForm()" with onClick={submitForm} in your component.
- Move <script> tags out: script tags pass through unchanged, so lift the logic into your component instead of leaving a script tag in JSX.
- Check data-* attributes and other void elements: the converter renames any attribute matching class=, so an attribute such as data-class= can be renamed to data-className= by mistake — and void elements outside the seven handled ones (area, base, col, embed, track, wbr) are left unclosed, so close them yourself.
Common Mistakes
- Leaving HTML comments in — they pass through unchanged, and raw HTML comments are invalid in JSX, so rewrite them as {/* */} first.
- Expecting <script> tags to be converted — they pass through unchanged; move the logic into your component.
Limitations
Inline <script> tags and HTML comments are not converted or removed — they pass through unchanged. Event attributes are renamed to React props but their code is not converted.
Structured Input/Output Example
<div class="alert"><label for="email">Email</label><input type="email">
<div className="alert"><label htmlFor="email">Email</label><input type="email" /></div>
Related Tools
JSX to HTML
Convert JSX snippets to plain static HTML. Free offline tool for emails, CMS embeds & static pages. className → class handled automatically.
Markdown to HTML Converter
Convert Markdown to clean HTML in your browser — GFM tables, task lists, footnotes and code blocks, live preview, sanitized by construction. Free, offline.
HTML Formatter
HTML formatter: turn minified or messy HTML into clean, indented markup. Nested tags aligned, attribute spacing normalized — view-source, readable.
JSON Formatter
JSON formatter: turn minified or messy JSON into readable, indented output. 2 spaces, 4 spaces, or tabs — paste, click Format, copy or download.