CSV to XML converter
Paste CSV with a header row and get XML with the root and row names you choose. Characters like & and < are escaped, headers that cannot be XML names are repaired, and you can write cells as child elements or as attributes.
Runs in your browser: nothing you enter is sent anywhere.
How to use it
- Paste CSV, or type it; the first row is treated as column names unless you turn that off.
- Set the root element (it wraps everything) and the row element (one per CSV line).
- Pick the delimiter, indentation and whether cells are child elements or attributes.
- Copy the XML.
Example
With root people and row person, the line 1,Ada Lovelace,London,"Math, poetry" becomes:
<person>
<id>1</id>
<name>Ada Lovelace</name>
<city>London</city>
<note>Math, poetry</note>
</person>
In attribute mode the same row is <person id="1" name="Ada Lovelace" city="London" note="Math, poetry"/>.
Tips
- If the first row is not a header, turn the option off to get column1, column2 and so on.
- For the reverse direction or nested data, use the JSON to XML converter.
Frequently asked questions
How are special characters handled?
Ampersands, less-than and greater-than signs are escaped in element text (&, <, >), and quotes are escaped in attributes. Control characters that XML 1.0 forbids are removed.
What happens to headers that are not valid XML names?
XML names must start with a letter or underscore and cannot contain spaces. Other characters become underscores, a leading digit gets an underscore in front, names beginning with "xml" (reserved) get one too, and empty or repeated names are numbered. The page lists every change.
How are empty cells written?
As empty elements such as <note/>. In attribute mode the attribute is written with an empty value.
What if a row has fewer or more cells than the header?
Missing cells are written empty. Extra cells get the names column4, column5 and so on, by position.
Can it handle quoted fields with commas and line breaks?
Yes. The parser follows the usual CSV rules: a field in double quotes may contain the delimiter, line breaks and doubled quotes ("").