Skip to main content
CalcChef

XML to CSV Converter

XML to CSV: each child of the root element becomes a row, its tags become columns and attributes @ columns, with a comma, semicolon, tab or pipe delimiter. How it works

Use the XML to CSV Converter

Tag names separated by /, such as catalog/item. Each matching element becomes one row. Leave empty to use the children of the root element.

Click to upload or drag and drop

XML files only (.xml, .txt)

CSV output
Paste XML to convert

About the XML to CSV Converter

To convert XML to CSV, each child element of the root becomes one row, each tag inside it becomes a column, and each attribute becomes a column named with @. Two <person> records with <name>, <age> and <city> and an id attribute give two rows such as John Smith,30,New York,1. Nested elements are not split into their own columns: their text is joined into one cell, unless you set a Record path such as orders/order/addr, which makes every matching element a row.

How to use this tool

  1. Paste the XML into XML Input, drop a .xml or .txt file on the upload area, or press Load Sample.
  2. For nested XML, type a Record path such as catalog/item: each matching element becomes a row. A bare name matches at any depth, and a leading / starts at the root.
  3. Pick the delimiter (comma, semicolon, tab or pipe) and the quote character, and choose whether to include the header row.
  4. Check the Structure Preview: root element, data rows, columns and the column names.
  5. Copy the CSV, or download it as a .csv file named after the root element.

Frequently asked questions

How do I open the CSV in Excel?
Download it and open it, or in Excel use Data, From Text/CSV and pick the file. If your Excel expects semicolons (common where the decimal separator is a comma), choose Semicolon before downloading. The download starts with a UTF-8 byte-order mark, so Excel reads accented letters correctly when you open it. Text you copy and paste has no mark; if accents look wrong after pasting it into a file, import that file through From Text/CSV and set the file origin to UTF-8.
Why do some cells start with an apostrophe?
A cell that starts with =, + or @, or with a minus followed by a letter or one of ( = + - @, could run as a formula when a spreadsheet opens the file. The converter puts an apostrophe in front of such a cell, so -A1 and +1 are written with a leading apostrophe. A plain negative number such as -5 is left alone.
What happens to repeated child elements?
Only the first one with a given name is kept in the row. If an order has three <item> elements, the item column holds the first. To get every item, set the record path to item (or orders/order/item): each <item> becomes its own row, although that row has no columns from its order.
Does it handle namespaces?
Yes, when the prefix is declared, as in a Google Shopping feed with xmlns:g on the root: <g:price> becomes a column called g:price. A prefix that is used but never declared makes the XML invalid, and the converter shows an error instead of output.
Is there a size limit?
The Max rows field converts up to 100,000 rows, 1,000 by default, and warns when the XML has more. XML longer than 5 million characters is refused with a message. The whole document is parsed in the browser tab, so a large file can make the page slow.

Related Tools

View all tools