CSV to XML Converter
Convert CSV data to XML format
Tip: The first row will be used as XML element names. Each data row becomes a <row> element.
Input CSV
Convert CSV to XML in your browser
Paste CSV, open a .csv file or drop it on the input window, and the XML appears as you type. The document has one <root> element with a <row> for each line of data, and inside every row one element per column, named after the header. Copy the result or download it as an .xml file.
Quoted fields are read by the rules of RFC 4180, the format spreadsheets export, so a value like "Portland, OR" stays one element instead of splitting into two. If you are still choosing a format for the export, XML vs JSON compares the two.
CSV to XML example
Real output for a two-row export. Each column becomes a child element of its row:
id,name,city,zip,active
1,Mara Quill,"Portland, OR",97201,true
2,Theo Brandt,Boston,02134,false
<?xml version="1.0" encoding="UTF-8"?>
<root>
<row>
<id>1</id>
<name>Mara Quill</name>
<city>Portland, OR</city>
<zip>97201</zip>
<active>true</active>
</row>
<row>
<id>2</id>
<name>Theo Brandt</name>
<city>Boston</city>
<zip>02134</zip>
<active>false</active>
</row>
</root>
How column names become tag names
A CSV header can hold any text, an XML name cannot. The converter fixes each name so the document stays valid:
-
CSV header
first nameXMLBecomes
<first_name>. Spaces and any character other than letters, digits,_,-and.turn into underscores. -
CSV header
2024,xml_idXMLBecome
<_2024>and<_xml_id>. An XML name cannot start with a digit or with the letters xml, so an underscore is put in front. -
CSV header
@idXMLBecomes an attribute of the row:
<row id="bk101">. Start a column name with @ to get an attribute instead of an element. -
CSV header
,,XMLAn empty header cell becomes
<column_3>, numbered by its position, and a repeated name such as a secondemailbecomes<email_4>.
Values, escaping and empty cells
Written into the XML
- Every value as text, exactly as in the CSV:
02134and4.50keep their zeros &,<,>and"escaped as&,<,>and"- An empty cell as a self-closing tag, such as
<zip/>
Not done
- Rename
<root>and<row>: change them in the output if your import expects other names - Build nested elements from names like
address.city: it becomes one element,<address.city> - Write a schema or namespaces
Need the CSV back?
The XML to CSV converter turns repeated elements back into rows, with attributes as @name columns.
CSV to XML questions
Click Open file and pick the .csv, or drop the file on the input window. It is read in your browser and converted straight away; Download saves the result as an .xml file.
Its column name starts with a digit or with xml, which XML does not allow for element names. The underscore keeps the document valid: a column called 2024 becomes <_2024>.
Yes. Give the column a name that starts with @, such as @id, and its value is written as an attribute of each <row> element.
No. XML has no number type, so every value is element text, written exactly as in the CSV. A schema or the program that reads the XML decides what is a number.
No. Converting runs in your browser, and an opened file is read there too.