FormatterHQ

HTML Table to XML Converter

Turn the rows of an HTML table into well-formed XML records. Name the root and row elements, keep or drop the XML declaration, and get valid element names automatically.

Input HTML
Output XML
Ready.

How to use the HTML Table to XML Converter

  1. Paste the HTML with your <table>, upload an .html file, or use Load URL.
  2. Enter a Root element and an Array item element name, for example parts and part.
  3. Adjust First row is header, Detect numbers & booleans, XML declaration and Indent as needed.
  4. Click Convert to XML and copy or download the output.

HTML to XML: table data as records

HTML tables and XML documents look related, but they serve different purposes: a table describes how data is displayed, while XML describes what the data is. This html to xml converter reads the cells of a table and writes each row as a record element with one child per column, named after the column heading. The result is data you can feed to an XML import, transform with XSLT or query with XPath.

It is not an HTML-to-XHTML converter. Page structure, attributes and formatting are dropped on purpose; only the tabular content is kept.

Example: a parts list

<table>
  <tr><th>Part no.</th><th>Unit price (USD)</th><th>Qty</th></tr>
  <tr><td>X-1</td><td>4.20</td><td>10</td></tr>
  <tr><td>Y-2</td><td>13</td><td></td></tr>
</table>

With Root element parts and Array item element part:

<?xml version="1.0" encoding="UTF-8"?>
<parts>
  <part>
    <Part_no.>X-1</Part_no.>
    <Unit_price__USD_>4.2</Unit_price__USD_>
    <Qty>10</Qty>
  </part>
  <part>
    <Part_no.>Y-2</Part_no.>
    <Unit_price__USD_>13</Unit_price__USD_>
    <Qty/>
  </part>
</parts>

How headings become element names

Column headings are rarely valid XML names, so each one is cleaned: spaces, parentheses and other symbols become underscores, while letters, digits, hyphens, periods and colons are kept. That is why Unit price (USD) turns into Unit_price__USD_. A heading that starts with a digit, or with the letters xml, gets a leading underscore. If you control the source table, short one-word headings produce the cleanest XML.

Headings that begin with the Attribute prefix (@ by default) become attributes of the row element instead of child elements, so a column titled @id yields <part id="…">.

Values, empty cells and types

With Detect numbers & booleans on, plain numbers are normalized before writing, so 4.20 appears as 4.2. Turn the option off to keep the exact cell text. Empty cells produce self-closing elements like <Qty/>. Characters such as & and < are escaped in the output.

Multiple tables

If the input contains several top-level tables, all of them go under the root element, and each row element is named after its table's id (or table1, table2 when there is none). The item name setting is used only for single-table input.

To check the result, run it through the XML validator or reformat it in the XML formatter. If you only need the data for code, HTML to JSON is usually simpler to work with.

Privacy

Everything runs in your browser. Load URL is fetched through our server, and Save & Share stores your input; nothing else leaves your device.

Frequently asked questions

Why does my XML contain names like Unit_price__USD_?
XML element names cannot contain spaces or parentheses. Each invalid character in a heading is replaced with an underscore so the document stays well-formed.
Can a column become an XML attribute?
Yes. Start the column heading with the attribute prefix, @ by default. The column is then written as an attribute on the row element.
Does this convert HTML pages to XHTML?
No. Only table cell text is extracted and written as data records. For cleaning up page markup, use an HTML formatter instead.
What happens without a header row?
Untick First row is header and each row becomes a list of values written as repeated item elements, without column names. That is valid XML but harder to use, so a header row is recommended.

Last updated October 3, 2026

Related tools