Danial
Posted on Nov 20
Edited on Nov 20
I made a small tool: paste HTML, get React JSX or a typed component. It's free, needs no signup, and runs in your browser. The link is at the end.
The problem
HTML and JSX look alike, but they differ in small, annoying ways. class has to become className , for becomes htmlFor , inline style="..." strings must turn into objects, and void tags like <img> and <input> must be self-closing. When you paste a big chunk of markup from a template, a design export or an old page, fixing all of this by hand is slow and easy to get wrong.
What the converter does
Converts attributes to their JSX names ( class to className , for to htmlFor )
Turns inline style strings into style objects with camelCase properties ( background-color becomes backgroundColor )
Self-closes void elements
Converts hyphenated SVG attributes to camelCase ( viewBox , strokeWidth )
Can wrap the result in an exported component, with TypeScript typing ( React.FC )
Example
Input:
<div class =…