consolelog.tools

HTML to JSX

Convert HTML to correct React JSX — full DOM & SVG attribute renaming (readOnly, tabIndex, strokeWidth), event handlers, idiomatic booleans, style objects. Live, with a conversion summary.

About this ToolHow it works, benefits & use cases

Paste a block of HTML and this converter rewrites it as React-correct JSX as you type. It renames the full set of DOM and SVG attributes to their camelCase React names — class becomes className, for becomes htmlFor, and readonly, tabindex, maxlength, stroke-width, fill-rule, clip-path and dozens more are mapped accurately rather than left as invalid props. Inline style strings are parsed into JSX style objects with camelCased keys (including vendor prefixes and CSS custom properties), event attributes like onclick become onChange-style handlers, void elements such as img and input are self-closed, HTML comments turn into {/* … */}, and common named entities are decoded. You choose double or single quotes, idiomatic bare booleans or explicit ={true}, and whether to wrap the result in a fragment or a full component. Everything runs in your browser with a live conversion summary — no upload, no sign-up.

How to Use

  1. 1Set your options first: pick double or single attribute quotes, choose whether to wrap the output in a fragment or a named component, and toggle "Explicit booleans" if you want disabled={true} instead of a bare disabled.
  2. 2Paste your HTML into the input panel, or click "Load example" to drop in a sample card with styles, SVG, entities and boolean attributes.
  3. 3The JSX regenerates live as you edit — press "Convert to JSX" to validate non-empty input.
  4. 4If you chose the component wrapper, type a component name; it is sanitised to a valid PascalCase identifier and used for the download filename.
  5. 5Review the conversion summary to see counts of renamed attributes, styles, comments and self-closed elements, then copy, download, or share the JSX.

Key Benefits

  • Renames the complete React DOM attribute set plus SVG presentation attributes (strokeWidth, fillRule, clipPath, and more)
  • Converts inline style="" strings into proper JSX style objects, handling vendor prefixes and --custom-properties
  • Rewrites event attributes like onclick and ondblclick to onClick and onDoubleClick
  • Self-closes void elements and converts HTML comments to JSX comment syntax
  • Idiomatic bare booleans by default, or explicit ={true} when you prefer it
  • Optional fragment or full-component wrapper with a sanitised PascalCase name
  • Live preview, a per-conversion summary, and shareable output URLs — all in-browser

Common Use Cases

  • Porting a static HTML template or design export into a React component
  • Fixing invalid props (class, for, readonly, tabindex) when pasting markup into JSX
  • Converting inline-styled snippets into React style objects without hand-editing
  • Migrating SVG icons into React where kebab-case attributes break the build
  • Scaffolding a component file directly from HTML with the component wrapper option

Options

disabled={true} instead of idiomatic bare disabled

0 characters · live

Paste HTML above to see the converted JSX.

Attribute reference

classclassName
forhtmlFor
tabindextabIndex
readonlyreadOnly
maxlengthmaxLength
colspancolSpan
rowspanrowSpan
autocompleteautoComplete
autofocusautoFocus
contenteditablecontentEditable
crossorigincrossOrigin
srcsetsrcSet
enctypeencType
onclickonClick
onchangeonChange
stroke-widthstrokeWidth
fill-rulefillRule
clip-pathclipPath

Was this tool helpful?

Share Your Experience

Help others discover this tool!

Related tools