XML to CSV Converter

Convert repeating XML records into CSV rows. Each child of the root element becomes a row, and its child elements and attributes become columns.

Copied
XML Input0 B
CSV Output0 B

What the XML to CSV converter does

XML (XML 1.0) is a tree; CSV (RFC 4180) is a flat table. This converter handles the most common shape of data XML — a root element holding a list of similar records — and turns it into one CSV row per record. Each record's child elements and attributes become the columns, and the header lists every column found in any record.

The input is parsed by your browser's own XML parser, so it must be well-formed. Entities such as & and é are decoded and CDATA sections are read as plain text before the values are written to CSV.

How to use it

  1. Paste XML into the XML Input pane, load a file with File, or fetch a feed with URL (the server must allow cross-origin requests).
  2. Click Convert.
  3. Use Copy, or Download to save converted.csv. Clear empties both panes.

There are no options. Output is comma-separated with LF line endings, and values containing a comma, a quote or a line break are quoted.

Conversion rules

Example

<products>
  <product sku="A1"><name>Desk lamp</name><price>29.00</price></product>
  <product sku="B7"><name>Chair, oak</name><price>149.00</price><stock>4</stock></product>
</products>

converts to:

@sku,name,price,stock
A1,Desk lamp,29.00,
B7,"Chair, oak",149.00,4

The first product has no <stock>, so its cell is empty, and Chair, oak is quoted because it contains a comma. A book with two authors, <book><title>A</title><author>X</author><author>Y</author></book>, gives the header title,author,author[2].

Converting RSS and other wrapped feeds

Many feeds put the records one level down. In RSS 2.0 the root is <rss>, its only child is <channel>, and the <item> elements sit inside that. Converting the whole document gives a single row with the items as XML in item, item[2] and so on. Paste just the <channel> element instead: each <item> becomes a row. The channel's own <title> and <link> also become a row, which you can delete. Any namespace prefixes the items use, such as g: in a Google product feed, must still be declared on the element you paste, or the parser rejects it.

Common problems and fixes

SymptomCauseFix
An error from the XML parserThe input is not well-formed: an unclosed tag, an unescaped &, or an undeclared prefix. The wording comes from your browser, so it differs between Chrome, Firefox and Safari.Check and fix it in the XML Formatter, which points to the line and column.
“No repeated child records found under the root element”The root element is empty or has only text.Paste the element that contains the records.
Only one row, full of XML markupThe records are wrapped one level deeper than the root.Paste the inner wrapper element, as described for RSS above.
A cell contains xmlns="..."Nested markup in a namespaced document is written with its namespace declaration so it remains valid XML on its own.Expected; remove it with find and replace if you do not need it.

Frequently asked questions

Why is one of my cells full of XML tags?

That child element has children of its own. A CSV cell holds only text, so the converter keeps the nested part as markup instead of dropping it. If you need those values in their own columns, extract that level first, or convert to JSON with XML to JSON to keep the structure.

Does it work with a large export file?

There is no size limit in the tool. The whole document is parsed in memory by the browser, so the practical limit for very large files is the memory available to the page.

Can I pick which elements become columns?

No. Every child element and attribute of a record becomes a column. Delete the columns you do not need in a spreadsheet afterwards, or remove the elements from the XML before converting.

Will converting back with CSV to XML give me the same XML?

Not usually. CSV to XML always writes <rows> and <row> elements, turns attribute columns such as @sku into child elements named _sku, and does not rebuild nested markup.

Is the XML uploaded to a server?

No. Parsing uses the browser's built-in DOMParser and the conversion runs on your device. The URL button is the only thing that makes a request, and it goes from your browser straight to the address you enter.

Related tools