About the HTML to JSX Converter tool
Pasting HTML into a React component almost never works first time. JSX needs className instead of class, htmlFor instead of for, style objects instead of style strings, closed void tags, camelCase attributes and a single root element. Fixing all of that by hand in a large template is slow and error-prone. This converter does it automatically.
Your HTML is parsed with the browser's DOMParser and rebuilt as JSX. Attributes are renamed to their React equivalents, such as tabindex to tabIndex, maxlength to maxLength and SVG attributes like stroke-width to strokeWidth. Inline styles become objects with camelCased properties, vendor prefixes like WebkitBorderRadius and CSS variables kept as quoted keys. Inline event handlers such as onclick become onClick with an arrow function, comments become {/* */}, and braces or angle brackets in text are escaped.
Optionally the result is wrapped in a named component with a fragment around multiple root elements, and value or checked on form fields can become defaultValue and defaultChecked so React does not warn about uncontrolled inputs. Conversion is instant and runs in your browser.
How to use HTML to JSX Converter
- Paste HTML into the “HTML” pane, open a file, or click “Load sample”.
- Turn “Wrap in a component” on or off and set a “Component name”.
- Choose whether to use “Uncontrolled inputs” and pick the indentation.
- Copy the “JSX” output or download it as a .jsx file.
Features
React attribute names
class, for, tabindex, colspan, readonly, SVG attributes and more are renamed correctly.
Style strings to objects
CSS declarations become camelCased style objects, including vendor prefixes and custom properties.
Event handler conversion
onclick and other inline handlers become camelCase props with arrow functions.
Valid JSX structure
Void tags are self-closed, comments become JSX comments and multiple roots get a fragment.
Component wrapper
Optionally outputs a ready-to-use export default function component.
When to use it
- Move a Bootstrap or Tailwind HTML template into a React or Next.js app.
- Convert SVG icons into JSX for inline React components.
- Port static landing pages into a React codebase.
- Turn HTML snippets from documentation into JSX examples.
- Save time when rebuilding legacy pages as components.
Frequently asked questions
Does it convert onclick handlers correctly?
It turns onclick="doThing()" into onClick={() => { doThing(); }}. Functions it calls must exist in your component scope, so review handlers after conversion.
What happens to <script> and <style> tags?
Style content is kept in a template literal, and scripts use dangerouslySetInnerHTML. In React it is usually better to move them into CSS files or effects.
Can I convert SVG to JSX?
Yes. Hyphenated SVG attributes such as stroke-linecap and fill-rule become camelCase, and xlink:href becomes xlinkHref.
Does it work for Vue or Svelte?
No. The output is JSX for React, Preact, Solid and similar libraries.
Is my code uploaded?
No. The conversion runs in your browser.