Convert XML to HTML tables people can read
XML is precise but tiring to read, especially for colleagues who do not work with markup every day. This XML to HTML converter turns the data in an XML document into a plain HTML table: records become rows, fields become columns, and the result can be pasted into a CMS, a Confluence or wiki page, a README or an email. The Preview tab shows exactly how it will look.
Note that this is a data conversion, not an XSLT transformation. If you need full control over the generated markup, use the XML XSL transform tool with your own stylesheet.
Example
<list>
<p name="A & B">x < y</p>
<p name="C">z</p>
</list>
produces
<table>
<thead>
<tr>
<th>@name</th>
<th>#text</th>
</tr>
</thead>
<tbody>
<tr>
<td>A & B</td>
<td>x < y</td>
</tr>
<tr>
<td>C</td>
<td>z</td>
</tr>
</tbody>
</table>
Values are HTML-escaped, so characters like & and < in your data display correctly and cannot break the page. The #text column holds element text that sits next to attributes.
Layout options
- Auto (default) – uses one flat table when every record contains only simple values, and switches to nested tables as soon as records contain nested elements or lists.
- Single flat table – always one table. Nested elements are flattened into dot-notation columns such as
address.city, and repeated children into numbered columns likeskills.skill.0. - Nested tables – mirrors the XML hierarchy: each element with children becomes a key/value table, lists of records become tables with header rows, and lists of simple values become bullet lists inside the cell.
Flat tables are easier to sort and copy into spreadsheets. Nested tables are better for documents where the structure itself matters, such as a configuration file with sections.
Styling options
Styling controls whether a <style> block is placed before the table:
- No CSS – bare table markup that inherits your site's styles.
- Bordered – cell borders, padding and a blue header row with white text.
- Striped rows – the same, plus alternating row backgrounds for long tables.
The styles use simple element selectors (table, th, td), so if you paste the output into a page that already styles tables, either choose No CSS or scope the rules to a class.
How XML maps to the table
- The repeated element under the root becomes the rows; single wrapper elements are skipped.
- Attributes become columns named with the Attribute prefix (
@by default); clear it for plain headers. - Detect numbers & booleans affects typing only; in HTML every value is displayed as text.
- Comments, processing instructions and the XML declaration are not shown.
Related tools
If the goal is a spreadsheet rather than a web page, use XML to CSV. To build a table by hand, try the HTML table generator, and to format the resulting markup, the HTML formatter can re-indent it.
Privacy
The conversion and preview happen in your browser. Your XML is sent to our server only if you use Load URL or Save & Share.
Convert XML to an HTML table in Python
Read the XML with xml.etree.ElementTree and print one table row per record. ElementTree returns decoded text, so Tea & Code in the source arrives as Tea & Code; written straight into HTML, the ampersand is no longer escaped. Pass every value through html.escape() on the way out. Use findtext() with a default so that a record without a given child still yields an empty cell instead of None.
import html
import xml.etree.ElementTree as ET
data = """<catalog>
<book id="b1"><title>XML Guide</title><price>29.99</price></book>
<book id="b2"><title>Tea & Code</title></book>
</catalog>"""
root = ET.fromstring(data)
print("<table>")
print(" <tr><th>id</th><th>title</th><th>price</th></tr>")
for book in root.iter("book"):
values = [book.get("id"), book.findtext("title", ""), book.findtext("price", "")]
print(" <tr>" + "".join(f"<td>{html.escape(v)}</td>" for v in values) + "</tr>")
print("</table>")
The converter above builds the same kind of table from any XML and works out the columns for you.