1001Ferramentas
🔄Converters

JSX to HTML Converter

Converts JSX (React) syntax to plain HTML by mapping className to class and camelCase attributes to kebab-case.

JSX to HTML: where kebab-case lies

You have a block of JSX, a card or an SVG icon, and you need it as plain HTML for an email, a Handlebars template or a static landing page. Pasting it as is does not work: className is not an attribute and a JSX comment shows up as visible text. This page swaps className for class and htmlFor for for, turns JSX comments into HTML comments, and rewrites everything in camelCase into kebab-case.

That kebab rule is right for SVG and wrong for HTML. In SVG, strokeWidth really does become stroke-width and fillRule becomes fill-rule. HTML attributes, though, are lowercase with no hyphen: tabIndex is tabindex, readOnly is readonly, maxLength is maxlength, and the conversion hands you tab-index, read-only and max-length, which the browser ignores. The swap also applies to the whole text, so onClick becomes on-click and a MyCard component becomes My-card.

Use it on JSX that is basically markup: structure, classes, SVG. Once converted, sweep the output for hyphens that should not be there, delete the expression braces, and drop the event handlers, which have no HTML equivalent. If the component carries logic, a conditional or a map, this page will not help and that part has to be rewritten by hand. Everything happens in the browser, with nothing uploaded.

Frequently asked questions

Does it convert HTML back into JSX?
No, it only goes one way. For the reverse, the minimum is class to className, for to htmlFor, and self-closing the void tags such as the line break.
Why does my paragraph text have hyphens in it?
The camelCase rule cannot tell an attribute from content. A word like iPhone comes out as i-phone, so read the output before you ship it.
What about style with a double-brace object?
Not handled. In HTML the style attribute takes a string of CSS declarations, not an object, so that part gets rewritten by hand.

Related Tools