Convert HTML Table to XML Online
Convert an HTML table into XML data, with one element per row. The markup is read in your browser and never uploaded.
Drop a CSV or Excel file here
CSV · XLSX · XLS · XLSM · XLSB
Ready to download as a binary file.
How to convert an HTML table to XML
Three steps from staff.html to XML.
1. Paste the HTML
Paste markup that contains a <table>, or drop an .html file.
2. Check it in the grid
Rename headers in the grid if the tag names must match a schema: E-mail becomes E_mail and Ext. becomes Ext_.
3. Name the tags
Set the root and row tag names, choose elements or attributes, toggle pretty printing, then copy or download data.xml.
Example: HTML in, XML out
A staff directory with a mailto link, punctuation in the headers and an empty extension.
<table>
<tr><th>Name</th><th>E-mail</th><th>Ext.</th></tr>
<tr><td>Ana Lima</td><td><a href="mailto:[email protected]">[email protected]</a></td><td>214</td></tr>
<tr><td>Ben Ortiz</td><td>[email protected]</td><td></td></tr>
</table><?xml version="1.0" encoding="UTF-8"?>
<rows>
<row>
<Name>Ana Lima</Name>
<E_mail>[email protected]</E_mail>
<Ext_>214</Ext_>
</row>
<row>
<Name>Ben Ortiz</Name>
<E_mail>[email protected]</E_mail>
<Ext_></Ext_>
</row>
</rows>The mailto link is reduced to its text, and Ben's empty extension gives an empty <Ext_></Ext_> element.
What changes between HTML and XML
Tag names come from headers
Column elements are named after the headers, made safe for XML: "E-mail" becomes <E_mail> and "Ext." becomes <Ext_>. A header starting with a digit gets a col_ prefix.
Attributes mode
Each row becomes one empty element with an attribute per column: <row Name="Ana Lima" E_mail="[email protected]" Ext_="214"/>
First row is the header
The first row (Name, E-mail and Ext.) becomes the header, whether its cells are <th> or <td>. colspan and rowspan would not be expanded, so check spanned rows in the grid.
When to convert HTML to XML
- Moving data from HTML pages into an XML-based pipeline.
- Producing an XML feed from a table published on a site.
HTML to XML in JavaScript
TabularJS reads HTML: every <table> becomes a worksheet. Then headers become tag names and values are escaped for XML.
import tabularjs from 'tabularjs';
// The first row of the table becomes the column titles
const { worksheets } = await tabularjs('staff.html', { tableIndex: 0 });
const header = worksheets[0].columns.map((col) => col.title);
const rows = worksheets[0].data;
const tag = (h) => String(h).trim().replace(/[^A-Za-z0-9_]/g, '_');
const esc = (v) => String(v ?? '').replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
console.log('<?xml version="1.0" encoding="UTF-8"?>\n<rows>\n' + rows.map((row) =>
' <row>\n' + header.map((h, i) => ` <${tag(h)}>${esc(row[i])}</${tag(h)}>`).join('\n') + '\n </row>'
).join('\n') + '\n</rows>');TabularJS differs from this page in two ways: it returns every <table> as a worksheet, and it turns colspan into mergeCells.
Frequently asked questions
Is this the same as converting HTML to XHTML?
No. XHTML keeps the page markup. This page extracts the table's values and writes them as data elements such as <row><Name>Ana Lima</Name>...</row>.
Can the header cells become attribute names?
Yes. Choose Attributes mode: each header becomes an attribute name, cleaned the same way as element names (E-mail becomes E_mail).
What about tables built with <div>s?
They can't be read. The converter needs real <table>, <tr>, <th> and <td> elements. For CSS grid or div layouts, copy the text and paste it as CSV instead.
Which characters are escaped?
The five XML specials: & < > " and ', written as & < > " '. Everything else, accents and emoji included, is written as is, in UTF-8 as the declaration says.
Does staff.html get uploaded when I convert it to XML?
No. The markup is read in your browser and never uploaded.