CSV XML Converter
Paste a CSV table to get one XML element per row, or paste XML with repeating records to get a CSV table with a column for each field.
Worked examples
CSV to XML
name,age Ann,31 "Bo, Jr",28
<?xml version="1.0" encoding="UTF-8"?> <rows> <row> <name>Ann</name> <age>31</age> </row> <row> <name>Bo, Jr</name> <age>28</age> </row> </rows>
The quoted value with a comma stayed in one field.
XML to CSV
<list><p id="1"><n>A</n><a><c>X</c></a></p><p id="2"><n>B</n><a><c>Y</c></a></p></list>
@id,n,a.c 1,A,X 2,B,Y
The attribute became @id and the nested element became a.c.
About CSV XML Converter
Tables and trees are different shapes of data. A spreadsheet holds a table of rows and columns, while XML holds a tree of elements. Many tools that import or export data still prefer XML, and many people still prefer to look at a table, so you often need to move from one to the other.
This converter writes each CSV row as an XML element, using the first row as the names of the fields, and reads XML back into a table by finding the records that repeat. Quoted CSV values that contain commas, quotes or line breaks are read correctly, field names that are not valid in XML are cleaned up and made unique, and nested elements in the XML become columns with dotted names such as address.city.
How to use CSV XML Converter
- Choose CSV to XML or XML to CSV.
- Paste the data. Leave the separator on detect, or choose comma, semicolon, tab or pipe.
- For CSV to XML, name the outer and row elements. For XML to CSV, name the record element if it is not found by itself.
- Copy the result. If something is wrong, the message names the line.
Common uses
- Preparing a spreadsheet export for a system that imports XML
- Turning an XML report into a table you can open in a spreadsheet
- Checking which fields every record in an XML feed has
- Converting test data between formats
Frequently asked questions
Which element names does it use?
The first CSV row supplies the names of the fields. The outer element is called rows and each record row by default, and you can change both.
What if my CSV has no header row?
Untick the option that says the first row holds the names and the columns are called column1, column2 and so on.
How does XML to CSV choose the records?
It looks for the elements that repeat under the root. If the file has a wrapper, such as a list inside a document, it goes down one level. Type the name of the repeating element if you want a different one.
What happens to attributes?
In XML to CSV each attribute becomes a column with @ in front of its name, such as @id. In CSV to XML every value becomes the text of an element.
Does it handle semicolon separated files?
Yes. Spreadsheets set to many European regions save CSV with semicolons. The detect option finds the separator from the first line.