About the HTML to JSX Converter
You paste HTML and get JSX or a ready React component back, all in your browser. You can pick output as plain JSX or wrapped as a React component. The page runs client-side only, so nothing you type or open is uploaded. You can copy the converted code with one click, or open an HTML file and download the converted result. The converter applies the standard React rules: rename class to className, for to htmlFor, convert inline style strings into JS objects, camelCase event names, and self-close void tags. That behavior matches the React docs and the JSX spec. The tool is useful if you need a quick conversion for snippets, templates, or small pages before you paste into your project. If you need large migrations or custom formatting, keep an editor like Prettier or a codebase script handy.
How to use it
- 1Paste your HTML into the left editor pane.
- 2Choose output mode: JSX or React component.
- 3Click Convert and then Copy to clipboard with one click.
- 4Or open an HTML file and then Download the converted file.
Worked example
Input HTML: <div class="card" style="font-size:14px;color:red">Hello</div> JSX output (JSX mode): <div className="card" style={{fontSize:"14px",color:"red"}}>Hello</div> React component output (component mode): export default function Component(){ return (<div className="card" style={{fontSize:"14px",color:"red"}}>Hello</div>); }
How it works
Parse the input HTML using an HTML parser (browser DOM or parse5) to produce a treeWalk the tree and rename attributes per React's DOM property table: class -> className, for -> htmlFor, tabindex -> tabIndex, maxlength -> maxLength, on* -> camelCase on*Convert inline style strings into JS object literals with camelCased property names (e.g., "font-size: 12px" -> {fontSize: "12px"})Self-close void elements (<br />, <img />, <input />)Preserve aria-* and data-* attributesHandle SVG by camelCasing mixed-case attributes like stroke-width -> strokeWidth and keeping viewBoxDo not upload input; run all steps client-sideSource: React docs, Writing markup with JSXJSX specification (React GitHub). Last checked 6 November 2026.
What it is good for
- Runs entirely in your browser so your markup stays on your device.
- One-click copy plus open file and download make quick edits fast.
- Converts styles, attribute names, events, and self-closing tags per React rules.
- The tool does not convert inline JavaScript logic into safe React handlers; you must wire functions and state yourself.
- Complex SVG edge cases or malformed HTML may need manual adjustment after conversion.
Questions people ask
Does this tool upload my HTML to a server?
No. The converter runs in your browser and processes data locally. Nothing you paste or open is sent to a server.
What exact changes will I see in the output?
Expect class to become className, for to become htmlFor, camelCased event names like onclick to onClick, inline style strings to JS object literals, and void tags to be self-closed.
Will it turn inline onclick handlers into working React code?
No. The tool renames attributes but does not convert inline script logic into component functions. You must move handlers into component code and reference them.
Does it keep aria-* and data-* attributes?
Yes. aria-* and data-* attributes are preserved unchanged and remain valid in JSX.
Can I get a ready-to-use React component file?
Yes. You can choose React component mode to wrap output in a simple component and then download the file. You may still need to add imports and state or handlers.
How does the tool handle SVG attributes?
It camelCases mixed-case SVG attributes like stroke-width to strokeWidth and keeps attributes such as viewBox. Complex SVG cases may require manual checks.
Help keep every tool free
FreeToolr stays free because people help it grow. Share a tool you like, tell us what to build next, or support us on Ko-fi.