XML to HTML Converter
CV-71Paste XML and get HTML that displays it: as an escaped code block, as a nested list, or as a table when the XML holds repeated records.
Runs in your browser. Nothing is uploaded.
XML
HTML
How to use it
- Paste your XML into the input box, or open a .xml file and drop it on the box.
- Choose Code block, Nested list or Table.
- Pick the indent, and for the code block you can wrap it in a full HTML page.
- Copy the HTML or download it as a .html file.
Code block
Code block escapes your XML exactly as typed, including comments and the XML declaration, and puts it in pre and code with a language-xml class. A browser then shows the markup as text instead of treating it as tags. Syntax colors are not added, but the class name lets a highlighter such as Prism or highlight.js pick it up. The XML is checked first, and malformed XML is rejected with its line and column.
Nested list and Table
Nested list writes an unordered list with the element name in bold, attributes as small spans and text after a colon. Comments and processing instructions are not shown. Table finds the first element that has repeated children and makes each repeat a row. Columns come from child element names and attributes, written as @id for an attribute, address.city for a nested element and tag[0], tag[1] for a repeated one. If nothing repeats, you get one row. Missing cells are empty.
What it does not do
It is not an XSLT processor, so it does not apply a stylesheet. A document that depends on custom entities declared in a DOCTYPE is rejected, because only the five built-in entities and numeric references are read. All text is escaped. No CSS is added to the output.
Error messages and what to do
| Message | What it means | Fix |
|---|---|---|
Expected </b> (opened on line 1) but found </a> at line 1, column 7 | A closing tag does not match the element that is open. | Close the tags in the reverse order that they were opened. |
Text before the root element at line 1, column 1 | The input starts with text that is not XML. | Paste XML that starts with an element such as <root>. |
Questions people ask
How do I display XML in HTML?
Escape it and put it in a pre element, which is what Code block does. Paste the XML, copy the result into your page, and the browser shows the markup as text.
How do I turn XML into an HTML table?
Choose Table. If the XML has repeated elements such as many book records, each becomes a row and the child elements and attributes become columns.
Does it keep comments and the XML declaration?
The Code block keeps them, since it shows your text exactly as typed. The list and table views do not show comments or processing instructions.
Does it run XSLT?
No. It does not read stylesheets or transform documents. It only shows the XML as a code block, a list or a table. If the output is not what you expect, check the input first.
Why was my XML rejected?
The code block checks that the XML is well formed first. The message gives the line and column of the first problem, such as a closing tag that does not match the opening tag.
About this tool
Code block escapes your XML exactly as typed, comments and declaration included, inside <pre><code class="language-xml">, so a browser shows the markup instead of running it. Nested list writes an unordered list with the element name in bold, attributes as small spans and text after a colon; comments and processing instructions are not shown. Table finds the first element that has repeated children and makes each repeat a row, with columns named after child elements and attributes (@id for an attribute, address.city for a nested element, tag[0] and tag[1] for a repeated one); if nothing repeats, you get one row. Missing cells are empty and everything is escaped. The XML is checked first and must be well formed; a document that depends on custom entities from a DOCTYPE is rejected. No stylesheet is applied, and XSLT is not run.