HTML to JSX Converter
Convert HTML to valid React JSX: class to className, for to htmlFor, inline styles to objects, self-closing tags and comments. Can wrap it in a component.
Runs in your browser. Nothing is uploaded.
About HTML to JSX Converter
Pasting plain HTML into a React component fails on several small differences. This converter fixes them: class becomes className, for becomes htmlFor, style strings become style objects with camelCase keys, void elements get a closing slash and HTML comments become JSX comments.
Attributes such as tabindex, onclick and maxlength are renamed to their React spellings. Tick the component option to get a ready-to-paste function component.
How to use HTML to JSX Converter
- Type or paste your text into the input box. Press Sample to see an example.
- Adjust the options. The result updates as you type.
- Copy the result, or press Use as input to chain another transformation.
Frequently asked questions
What happens to onclick handlers?
The attribute is renamed to onClick, but the string value is kept as a comment hint, because React expects a function, not a string of code.
Does it work for SVG?
Yes. Hyphenated SVG attributes such as stroke-width become strokeWidth.
Is HTML to JSX Converter free and private?
Yes. HTML to JSX Converter is completely free with no sign-up. Everything runs in your browser, so whatever you type or paste never leaves your device.