HTML to JSX Converter
Free HTML to JSX converter. Turn HTML or SVG into a React component with className, style objects, camelCase SVG attributes and self-closing tags.
This converter turns HTML or inline SVG into JSX you can paste into a React, Next.js, Preact or Solid component. It parses the markup with the browser's HTML parser, then renames attributes React expects differently (class to className, for to htmlFor, tabindex to tabIndex, stroke-width to strokeWidth), turns style strings into style objects, self-closes void tags such as img and br, converts comments, and escapes braces in text. It runs entirely in your browser.
Runs entirely in your browser and works offline. Nothing you enter or upload leaves your device. Free, no sign-up.
Features
- class → className, for → htmlFor and 50+ attribute renames
- style="…" → style={{ … }} objects
- SVG attributes to camelCase (strokeWidth, fillRule, xlinkHref)
- Self-closing void and empty tags
- HTML comments → {/* JSX comments */}
- Optional component wrapper; .jsx or .tsx download
How to use HTML to JSX Converter
- Paste HTML or SVG markup into the left editor (or press Sample).
- Choose whether to wrap it in a component and give the component a name.
- Copy the JSX from the right, or download it as a .jsx or .tsx file.
Frequently asked questions
Why can't I paste HTML straight into JSX?
JSX looks like HTML but compiles to JavaScript, so a few things differ: class and for are reserved words in JavaScript (className and htmlFor), style takes an object rather than a string, every tag must be closed (<br />), attributes are camelCase, and { } in text start a JavaScript expression.
How do I convert an SVG icon into a React component?
Paste the SVG markup, keep "Wrap in a component" on and give it a name such as ArrowIcon. The converter camelCases SVG attributes (stroke-width becomes strokeWidth, fill-rule becomes fillRule) so React does not warn about them. You can then add props such as className or width to the root <svg>.
What happens to onclick and other inline handlers?
They are renamed to React's camelCase events (onclick to onClick) and the code is wrapped in an arrow function. React passes an event object rather than evaluating a string, so check that the handler still refers to functions that exist in your component.
Why does value become defaultValue?
In React an input with value but no onChange is read-only (a controlled field). With the uncontrolled option on, value and checked become defaultValue and defaultChecked so the form still works as it did in plain HTML. Turn it off if you plan to wire up state.
Is the markup uploaded anywhere?
No. Conversion uses the HTML parser built into your browser and works offline; nothing is sent to a server.
Related tools
- HTML Formatter — Beautify and tidy HTML markup
- SVG Optimiser — Minify SVG exports and convert them to PNG
- JavaScript Minifier & Beautifier — Minify JS with Terser (mangle, compress, source map) or beautify it
- JSON to Code — Generate TypeScript, Zod, Go, Python or SQL from JSON
- CSS Minifier & Beautifier — Minify CSS with CSSO or prettify it, with a bytes and gzip savings report