HTML to JSX Converter
Convert plain HTML markup into JSX for React. It renames attributes such as class and for, turns inline styles into style objects, closes void tags like br and img, and turns HTML comments into JSX comments.
1 Paste or type your text
2 Your answer
Your answer shows here as you type.
How to use the HTML to JSX Converter
- Paste or type your HTML into the box.
- Read the converted JSX in the output.
- Copy the result into your React component and check any script or style blocks by hand.
Frequently asked questions
What changes when HTML is converted to JSX?
Attributes such as class become className and for becomes htmlFor. Inline style strings become objects with camelCase keys, void tags such as br and img get a closing slash, and HTML comments become JSX comments in curly braces.
Why does React use className instead of class?
class is a reserved word in JavaScript, so JSX uses className for the CSS class attribute. For the same reason, for is written as htmlFor on label elements.
Does the converter handle script and style blocks?
Not fully. Their contents are kept as text, so they need to be rewritten by hand, for example as a style object or a separate component.
How are event handlers like onclick converted?
An attribute such as onclick becomes onClick, and the original code is wrapped in an arrow function. In React it is usually better to replace that code with a named handler function.
Wrote something with AI? Slop Monkey rewrites it so it sounds like you, and keeps your facts.