CSV to XML Converter
Paste CSV or open a .csv file and get well-formed XML: the header row becomes element or attribute names, special characters are escaped correctly and the output is indented the way you like. Everything happens in your browser.
Your CSV is converted in this tab and never uploaded. Tip: Ctrl + Enter converts.
How to use the CSV to XML Converter
- Paste your CSV into the left box or open a .csv / .tsv file. A sample is loaded so you can see the result.
- Name the elements: the root element wraps everything and the row element wraps each record.
- Choose the layout: child elements or attributes, indentation and how empty cells are written.
- Check the delimiter. Auto-detect handles commas, semicolons, tabs and pipes; untick First row is the header if your file has none.
- Press Convert to XML, then Download .xml or Copy XML.
Example: CSV to XML
This CSV with a header row:
id,first name,email
1,Ada,[email protected]
2,Alan,"alan & [email protected]"becomes, with child elements and 2-space indentation:
<?xml version="1.0" encoding="UTF-8"?>
<rows>
<row>
<id>1</id>
<first_name>Ada</first_name>
<email>[email protected]</email>
</row>
<row>
<id>2</id>
<first_name>Alan</first_name>
<email>alan & [email protected]</email>
</row>
</rows>With Columns become: Attributes each row is a single element instead: <row id="1" first_name="Ada" email="[email protected]"/>.
XML naming and escaping rules
| Input | XML output | Why |
|---|---|---|
Header first name | <first_name> | Names cannot contain spaces |
Header 2024 sales | <_2024_sales> | Names cannot start with a digit |
Header price ($) | <price_> | Punctuation other than _ - . is not allowed |
Value Tom & Jerry | Tom & Jerry | & starts an entity reference |
Value a < b | a < b | < starts a tag |
Attribute value with " | " | Attribute values are wrapped in double quotes |
Tips
- Exporting from Excel: save as CSV UTF-8 so accented characters survive, then open the file here.
- Need a specific schema? Set the root and row names to what the importing system expects, for example
productsandproduct. - Check the result with the XML Formatter, or convert XML back with the XML to CSV Converter.
Frequently asked questions
How are CSV headers turned into XML tags?
Each header becomes an element (or attribute) name. Because XML names cannot contain spaces or most punctuation and cannot start with a digit, spaces are replaced with underscores, invalid characters are removed and names that start with a digit or with "xml" get a leading underscore. Duplicate headers get a numeric suffix. The message under the output lists every name that was changed.
Child elements or attributes: which should I use?
Child elements are the most common and are easiest to read and extend, and they keep line breaks in values. Attributes give a compact one-line-per-row format that many import tools and configuration files expect. Both are well-formed XML.
How are special characters escaped?
In element text, & becomes &, < becomes < and > becomes >. In attributes, double quotes become " and line breaks and tabs become character references so they survive parsing. Alternatively, tick the CDATA option to wrap text that contains <, > or & in a CDATA section. Control characters that XML does not allow are removed.
What if my CSV has no header row?
Untick First row is the header. The columns are then named column1, column2 and so on, and the first line is converted as data. You can rename the tags afterwards with a find and replace.
Does it support semicolon-separated files from Excel?
Yes. Auto-detect checks commas, semicolons, tabs and pipes and picks the one that splits the first lines into a consistent number of columns. You can also choose the delimiter yourself.
Are quoted fields with commas and line breaks supported?
Yes. The parser follows RFC 4180: fields in double quotes may contain the delimiter, line breaks and doubled quotes (""), which are read as a single quote character.
Is my data uploaded?
No. The CSV is parsed and the XML is generated by JavaScript in this page, so your file never leaves your device.