Skip to content

HTML to JSX Converter

JSX looks like HTML, but it isn't. React reuses JavaScript's variable-naming rules, which means 'class' becomes 'className', 'for' becomes 'htmlFor', and event handlers like 'onclick' become 'onClick'. Inline styles that were strings become JavaScript objects with camelCase property names. Void elements must self-close. This tool handles all of that in one paste-and-copy operation.

What Gets Converted

Attribute renames — class → className, for → htmlFor, tabindex → tabIndex, readonly → readOnly, maxlength → maxLength, and 30+ other renames. Event handlers — onclick → onClick, onmouseover → onMouseOver, onchange → onChange (all events camelCased). Void element self-closing — <img>, <input>, <br>, <hr> get proper <img /> syntax. Style strings to objects — 'color: red; font-size: 16px' becomes {{color: 'red', fontSize: '16px'}}. HTML comments — converted to JSX-compatible {/* */} syntax. Boolean attributes — checked, disabled, required become explicit true assignments.

📖
Deep Dive: The Complete HTML to JSX Guide
The full attribute rename list, inline-style object conversion, boolean attributes, edge cases with SVG and scripts, and what the converter leaves for you to wire up.

Common Use Cases

Porting a static landing page into a React component without manually fixing class vs className, for vs htmlFor, self-closing void elements, and inline-style strings on every element. Bringing a Figma-export or Webflow-export HTML snippet into a Next.js or Remix app. Cleaning up AI-generated HTML before pasting it into a JSX file so the build doesn't reject it for missing closes or stray boolean attributes.

Quickly checking what a chunk of marked-up content looks like in JSX form before committing to refactoring it into proper components — the conversion makes the syntactic friction visible at a glance. Every inline style attribute string becomes a JSX object literal, every tabindex becomes tabIndex, and every boolean attribute gets the right JSX shape, which helps scope the eventual cleanup.

How We Compare

VS Code extensions like "html to jsx" handle the conversion in your editor but require an install and ship varying levels of attribute coverage — some skip the inline-style transform entirely, which is the part that actually takes the longest by hand. Online converters from transform.tools and similar sites work but route your markup through their servers, which matters if the snippet contains internal copy, customer data, or unreleased designs.

This tool runs the conversion entirely client-side using a regex pipeline plus a parser pass for the trickier inline-style cases. Note that this is a syntax conversion, not a componentization: variables, props, event handlers, and conditional rendering are still your job once the JSX is valid. For pure beautification of either input or output, see code beautifier.

One JSX-specific point to remember: void elements (
, , ) must self-close as
in JSX. The converter handles that, but if you copy raw HTML into a JSX file later, the build error is usually about exactly this.

Frequently Asked Questions

Why can't I just paste HTML into a React component?+
JSX looks like HTML but isn't. 'class' is reserved in JavaScript, so React uses 'className'. Event handlers use camelCase (onClick, not onclick). Inline styles are JS objects, not strings. Void elements must self-close.
Does this handle inline styles?+
Yes. A style string like 'color: red; font-size: 16px' becomes a JSX object: {{color: 'red', fontSize: '16px'}}. CSS property names are converted to camelCase and values are wrapped in strings.
What about HTML comments?+
HTML comments (<!-- -->) are converted to JSX-compatible comments using curly braces and JavaScript comment syntax: {/* comment */}.
Will it wrap the output in a component?+
Optionally, yes. Toggle 'Wrap as component' to get a complete functional component with export default. Otherwise you get the raw JSX fragment.
What does the converter actually change?+
class → className, for → htmlFor, all attributes camelCased (onclick → onClick, tabindex → tabIndex), inline styles converted to object syntax, self-closing void elements (<br> → <br />), HTML comments to JSX comments, and entity decoding.
Does it handle SVG correctly?+
Yes — SVG attributes are camelCased (stroke-width → strokeWidth, xlink:href → xlinkHref). Output is ready to paste directly into a React component.
Can I generate functional component scaffolding?+
Toggle "wrap in component" and the output becomes a complete TSX/JSX function component with the converted markup as the return value. Useful for converting design-tool HTML exports.
What about inline event handlers like onclick="alert(1)"?+
They’re flagged with a warning — inline strings won’t work as JSX event handlers, which expect function references. The converter offers to wrap them in arrow-function syntax or leave them as comments for manual review.

Built by Derek Giordano · Part of Ultimate Design Tools

Privacy Policy · Terms of Service