Skip to content
Esc
  • MQTT Topic MatcherTest MQTT topic filters with + and # wildcards against topics, and check ACL patterns.
  • JSON FormatterBeautify, minify and validate JSON instantly as you type.
  • JSON DiffCompare two JSON documents and see every added, removed and changed value by path.
  • JSON to TypeScriptGenerate TypeScript interfaces or Zod schemas from a sample JSON response.
  • Base64 Encoder/DecoderConvert text to Base64 and back, with full Unicode support.
  • UUID GeneratorGenerate random v4 UUIDs — one or many — in the format you need.
  • JWT DecoderDecode JSON Web Tokens to inspect the header, payload and expiry.
  • Timestamp ConverterConvert Unix timestamps to dates and dates to timestamps.
  • URL Encoder/DecoderPercent-encode and decode URLs, and break down query strings.
  • Hash GeneratorGenerate MD5, SHA-1, SHA-256 and SHA-512 hashes of text or files.
  • Regex TesterTest regular expressions with live match highlighting and groups.
  • YAML to JSON ConverterConvert YAML to JSON and JSON to YAML, with clear error locations.
  • SQL FormatterBeautify or minify SQL for PostgreSQL, MySQL, SQL Server and 9 more dialects.
  • Mock Data GeneratorGenerate realistic fake data for API mocks as JSON, CSV or SQL inserts.
  • HTTP Header AnalyzerGrade response headers: CSP, HSTS, cookies, CORS and caching, explained.
  • Webhook Signature VerifierVerify and generate webhook signatures for GitHub, Stripe, Slack, Shopify and more.
  • Cron Expression GeneratorBuild and explain cron schedules, with the next run times in any time zone.
  • .env File ValidatorFind syntax errors, duplicates and missing keys in .env files.
  • HTML to JSX ConverterConvert HTML to valid React JSX: className, style objects, self-closing tags.
  • SVG to React ComponentTurn SVG files into React icon components with props and currentColor.
  • Markdown EditorWrite Markdown with a live preview, GitHub tables and task lists, and HTML export.

↑ ↓ to moveEnter to openPaste data to open it in the right tool. Nothing leaves your browser.

HTML to JSX Converter

Paste HTML from a template, a design tool or a code snippet and get JSX you can drop into a React component, with every attribute and style converted.

Last updated

HTML

JSX

Converted
<>
  {/* Sign-up card */}
  <div className="card" style={{ maxWidth: "420px", padding: "24px" }}>
    <h2 className="card-title">Create your account</h2>
    <form onSubmit={() => { handleSubmit(event); }}>
      <label htmlFor="email">Email</label>
      <input type="email" id="email" name="email" defaultValue="" required autoFocus />
      <label><input type="checkbox" name="updates" defaultChecked /> Send me product updates</label>
      <button type="submit" className="btn btn-primary" tabIndex="0">Sign up</button>
    </form>
  </div>
</>

Inline event handlers became arrow functions — check them, as they no longer receive a string.

value became defaultValue so the field stays editable without an onChange handler.

checked became defaultChecked so the box stays clickable without an onChange handler.

JSX needs a single root, so the elements were wrapped in a fragment (<>…</>).

How to use the HTML to JSX Converter

  1. Paste HTML

    Paste a snippet, a section or a whole page body.

  2. Choose options

    Keep or drop HTML comments, and optionally wrap the result in a component.

  3. Review the notes

    Notes explain conversions worth checking, such as event handlers and form values.

  4. Copy into your component

    Copy the JSX or download it as a .jsx file.

Features

  • class → className and for → htmlFor, plus 40+ other renamed attributes (tabindex, readonly, maxlength, colspan…)
  • Inline style strings become style objects, with camelCase properties and vendor prefixes
  • Void elements become self-closing (<br />, <img />, <input />)
  • Inline event handlers such as onclick become arrow functions with camelCase names
  • value and checked on form fields become defaultValue and defaultChecked
  • Comments become {/* */}, and { } in text are escaped
  • Several top-level elements are wrapped in a fragment
  • SVG attributes are converted to camelCase (stroke-width → strokeWidth)
  • Fixes unclosed tags and tells you where

Privacy

Your HTML is processed by JavaScript in your browser tab. Nothing is uploaded or stored, and the page's security policy blocks it from sending data to any other site.

Read the DevNest privacy policy

Examples

  • A form snippet

    class, for, the void <input> and an onclick handler are all converted.

    HTML

    <label for="email">Email</label>
    <input type="email" id="email" class="input" required>
    <button class="btn" onclick="subscribe()">Subscribe</button>

    JSX

    <>
      <label htmlFor="email">Email</label>
      <input type="email" id="email" className="input" required />
      <button className="btn" onClick={() => { subscribe(); }}>Subscribe</button>
    </>
  • Inline styles

    The style string becomes an object with camelCase properties.

    HTML

    <div class="alert" style="background-color: #fef2f2; border-left: 4px solid #ef4444; padding: 12px 16px">
      <strong>Device offline</strong> — last seen 5 minutes ago.
    </div>

    JSX

    <div className="alert" style={{ backgroundColor: "#fef2f2", borderLeft: "4px solid #ef4444", padding: "12px 16px" }}>
      <strong>Device offline</strong>{" "}
      — last seen 5 minutes ago.
    </div>
  • Comments, braces and two roots

    Comments become {/* */}, { } in text are escaped, and a fragment wraps both elements.

    HTML

    <!-- Readings -->
    <table class="readings">
      <tr><th colspan="2">dev-1042</th></tr>
      <tr><td>Temperature</td><td>21.4 °C</td></tr>
    </table>
    <p>Updated every {interval} seconds.</p>

    JSX

    <>
      {/* Readings */}
      <table className="readings">
        <tr>
          <th colSpan="2">dev-1042</th>
        </tr>
        <tr>
          <td>Temperature</td>
          <td>21.4 °C</td>
        </tr>
      </table>
      <p>Updated every {"{"}interval{"}"} seconds.</p>
    </>

Understanding JSX

How JSX differs from HTML

HTMLJSX
class="btn"className="btn"
for="email"htmlFor="email"
style="font-size: 14px"style={{ fontSize: "14px" }}
<br><br />
onclick="save()"onClick={() => { save(); }}
<!-- note -->{/* note */}
tabindex="0"tabIndex="0"

Things to check after converting

  • Event handlers: inline JavaScript becomes an arrow function, but it may reference globals that don't exist in your component. Usually you'll replace it with a handler function.
  • Form fields: value becomes defaultValue so the field stays editable. If you need a controlled input, switch back to value and add onChange.
  • <script> tags are kept as text; React doesn't run them. Load scripts another way, such as next/script.
  • Whitespace: JSX removes line breaks between elements, so the converter adds {" "} wherever the HTML had a space between inline elements.

Frequently asked questions

Why does React use className instead of class?

JSX compiles to JavaScript, where class is a reserved word, so React uses the DOM property name className. Likewise for becomes htmlFor.

How are inline styles converted?

A style string becomes an object with camelCase property names: background-color becomes backgroundColor, -webkit-line-clamp becomes WebkitLineClamp. Plain numbers stay numbers; everything else becomes a string.

What happens to multiple top-level elements?

A component must return one root, so the converter wraps them in a React fragment: <>…</>.

Does it work with SVG inside HTML?

Yes. Inside an <svg>, hyphenated attributes such as stroke-width become camelCase. For turning a whole SVG file into a component, use the SVG to React tool.

Will the output work in TypeScript (TSX)?

Yes. The JSX is the same in .jsx and .tsx files. Converted event handlers may need parameter types if you add them.