HTML to JSX
Paste HTML and get React JSX in this tab. class becomes className, for becomes htmlFor, and inline styles become a style object. The markup is parsed as text and is never rendered into this page. Nothing is uploaded.
Input
Result
How to use HTML to JSX
- Paste or open HTMLType, paste, or open a .html file. The limit is 1 MB. The markup is parsed as text and is not inserted into this page.
- Choose the output shapeConvert the HTML as JSX markup, or wrap it in a function component with a valid React component name such as Component.
- Copy or downloadCopy the JSX or download markup.jsx or component.tsx. The result is text only and is not executed here.
Limits and how it works
- The input is limited to 1 MB of UTF-8 text, including files you open, a maximum depth of 64, and a cap on how many nodes can be walked.
- The input is never rendered into this page. Script, style, and event-handler text can still appear in the downloaded JSX.
- HTML event-handler attributes are not turned into functions. You may need to rewrite them for React.
- This is a converter, not a linter. The JSX is not compiled or previewed here.
How HTML becomes JSX
This page uses parse5 8.1.1 (MIT), already in the project, to parse the HTML as a tree and write JSX. It does not add the htmltojsx package. That library is BSD-3-Clause, which is allowed, but version 0.3.0 depends on React 15, react-dom, and jsdom — too old and too large to ship here, and it is built around a DOM.
The converter never assigns the input to innerHTML, never uses DOMParser, and never appends the parsed tree to this document. You see the result only as text in the result box. Event-handler attributes such as onclick become camelCase string attributes, for example onClick, not JavaScript functions. Script and style contents are copied as text and are not run. This is not a sanitizer: unsafe markup can still appear in the JSX you download.
HTML attributes are mapped the way React expects: class becomes className, for becomes htmlFor, tabindex becomes tabIndex, and a style="…" string becomes a style={{ … }} object with camelCase keys. Void elements such as img and input are self-closing. Several root nodes are wrapped in a fragment. If you paste a full document, the doctype is omitted and the html tree is converted. parse5 repairs markup with HTML parsing rules; this is not a validator.
Frequently asked questions
Is my HTML uploaded?
No. Everything runs in your browser tab with JavaScript. Nothing you type, paste, or open is sent to a server, logged, or stored by ALink Tools.
Does this render my HTML on the page?
No. The HTML is parsed with parse5 as data and written back as JSX text. It is not inserted into the live document, so scripts and images in the input do not run or load as part of this page.
Is this the HTML to Markdown tool?
No. HTML to Markdown writes Markdown. This page writes React JSX.
Why don’t you use htmltojsx?
htmltojsx is BSD-3-Clause, but the published 0.3.0 package depends on React 15, react-dom, and jsdom. This page uses parse5 instead, which is already in the project under the MIT license.
Related tools
All toolsHTML to Markdown
Convert HTML to Markdown in your browser. Nothing is uploaded.
HTML Formatter
Pretty-print or minify HTML in your browser with js-beautify.
HTML Encoder / Decoder
Escape and unescape HTML entities without running or rendering the markup.
Markdown Editor
Write Markdown and preview sanitized HTML, then download .md or .html.