HTML to XML Online — HTML Tags to XML Elements

Turn HTML tags into XML elements in your browser. Nothing is uploaded, and the conversion stays on this tab.

Loading…
HTML → XML for fragments and snippets
Parses an HTML fragment in the browser and writes the element tree as XML, with attributes kept on their elements.

Examples

Article with a list

Input

<article class="release"> <h1>FastMinify 2.1</h1> <p>Browser-local converters and minifiers.</p> <ul> <li>40 format converters</li> <li>Zero server uploads</li> </ul> </article>

Output

<?xml version="1.0" encoding="UTF-8"?> <article class="release"> <h1>FastMinify 2.1</h1> <p>Browser-local converters and minifiers.</p> <ul> <li>40 format converters</li> <li>Zero server uploads</li> </ul> </article>

Fragment with a section and an id

Input

<section id="hero"> <h2>Try FastMinify</h2> <p>No uploads, conversion stays in your browser.</p> </section>

Output

<?xml version="1.0" encoding="UTF-8"?> <section id="hero"> <h2>Try FastMinify</h2> <p>No uploads, conversion stays in your browser.</p> </section>

How to convert HTML to XML

Paste an HTML fragment in the editor and select Convert. FastMinify parses it with the browser DOMParser (text/html) in this tab, then writes that tree as XML. Nothing is uploaded. When the input is a single-root fragment, meaning one element child of body such as the article and section samples above, that tag is the XML root. The output starts with <?xml version="1.0" encoding="UTF-8"?> and adds no <root> around that element. If you paste several top-level nodes (two paragraphs, mixed text and tags, or a body with more than one child), the converter wraps them in <root>. A body key from the HTML step is never unwrapped into a bare XML document, so mixed fragments stay one XML document without an invented html shell. Copy the result or download it after a successful conversion. To turn XML into HTML tables and lists, use XML to HTML. That page uses a different engine and is not a lossless reverse of this converter.

What this conversion preserves

The HTML parser lowercases tag names (DIV becomes div). Attributes stay on the matching XML element. Repeated sibling tags become repeated XML elements, not one merged node. Comments and processing instructions are dropped, because only element and text nodes are read. A full HTML document is not dumped byte for byte: the conversion uses the children of doc.body, so <html> and <head> are not reproduced. A document title appears only when the parser builds a { title, body } envelope, and even then it is written under <root>, never as a rebuilt <head>. Empty or void tags may be written as self-closing (<br/>, <img …/>) when they have no inner markup. A browser DOMParser is required, so the conversion runs in your tab and not on a server. This is not a stylesheet transform, not schema validation, not HTML Tidy and not XHTML polyglot output.

About these options

CSV exports: choose a delimiter (Auto follows locale — semicolon on /fr), RFC-minimal vs always-quoted fields, line endings, and whether to emit a header row. CSV imports: delimiter is auto-detected from the first line (comma, semicolon, tab, or pipe) — toggle whether row 1 holds column names. JSON output (XML, YAML, or CSV sources): indentation (including compact one-line) and optional recursive key sort. JSON → XML: toggle pretty-printing and indent width. YAML output: indent width, readable vs tighter layout, and deterministic string quoting (there is no source YAML file to “preserve”). XML comments are not represented in the intermediate JSON tree.

Related tools

Other converters that start from HTML are linked on this page.

HTML → XML FAQ

Parsing and limits

Is my HTML uploaded to a server?

No. The conversion uses the browser DOMParser in this tab, and FastMinify does not receive the markup.

Does an HTML document become XML ready for XSLT?

No. A single-element fragment becomes that element as the XML root, and several top-level nodes are wrapped in a root element. This is not an XSLT engine, a schema validator or HTML Tidy.

Can I download the result?

Yes. Use Download after a successful conversion.

Convert HTML to JSON, XML, YAML and Markdown.