FormatterHQ

XML to HTML Table Converter

Render XML data as an HTML table you can paste into a page, a wiki or an email. Choose flat or nested layout, add simple styling and preview it live.

Input XML
Output HTML
Ready.

How to use the XML to HTML Table Converter

  1. Paste XML into the input editor, upload an .xml file, use Load URL, or click Sample.
  2. Choose a Layout (Auto, Single flat table or Nested tables) and a Styling option; adjust the Attribute prefix if needed.
  3. Click Convert to HTML and open the Preview tab to see the rendered table.
  4. Copy the HTML from the Code tab or Download it.

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 &amp; B">x &lt; y</p>
  <p name="C">z</p>
</list>

produces

<table>
  <thead>
    <tr>
      <th>@name</th>
      <th>#text</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>A &amp; B</td>
      <td>x &lt; 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 like skills.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 &amp; 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 &amp; 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.

Frequently asked questions

Is this the same as transforming XML with XSLT?
No. This tool converts the data into a generic table automatically. XSLT lets you write a stylesheet that produces any HTML you want; use the XML XSL transform tool for that.
Why does my table contain tables inside cells?
Your records contain nested elements, so Auto layout chose nested tables. Pick Single flat table to get one table with dot-notation columns instead.
Can I add my own CSS class to the table?
Choose No CSS and add a class attribute to the tag after copying, or wrap the table in an element your stylesheet targets.
Is the HTML safe to paste into my site?
All values are HTML-escaped, so text from the XML is displayed rather than interpreted as markup. The output contains no scripts.

Last updated October 3, 2026

Related tools