CSV to XML Converter
Paste CSV and get well-formed XML wrapped in a root element with one element per row. The header row supplies the element names, which are sanitized into valid XML tags, and cell values have their ampersands and angle brackets escaped automatically. You can rename the root and row elements, and quoted fields containing commas or line breaks are parsed correctly under RFC 4180.
How to convert CSV to XML
- Paste your CSV into the CSV input box, or click Load sample.
- Set the Root element name (default root) and the Row element name (default row).
- Keep 'First row is a header' checked to turn the first row into element names, or uncheck it.
- Read the well-formed XML in the output box below.
- Use Copy, or Download to save it as data.xml.
Examples
Header row becomes element names
name,age Ada,36
<?xml version="1.0" encoding="UTF-8"?>
<root>
<row>
<name>Ada</name>
<age>36</age>
</row>
</root>A quoted comma stays inside one field
name,age,city Ada,36,Oslo "Doe, John",54,Bergen
<?xml version="1.0" encoding="UTF-8"?>
<root>
<row>
<name>Ada</name>
<age>36</age>
<city>Oslo</city>
</row>
<row>
<name>Doe, John</name>
<age>54</age>
<city>Bergen</city>
</row>
</root>Ampersands and angle brackets are escaped
company,tagline Acme,R&D <fast>
<?xml version="1.0" encoding="UTF-8"?>
<root>
<row>
<company>Acme</company>
<tagline>R&D <fast></tagline>
</row>
</root>Frequently asked questions
Is my CSV uploaded anywhere?
No. The conversion runs entirely in your browser, so your data never leaves your device and nothing is sent to a server.
How are the column element names chosen?
With a header row, each element name comes from the matching cell in the first row. Without a header, columns are named column1, column2 and so on, based on the widest row in the file.
What if a header is not a valid XML name?
The header is sanitized. Characters other than letters, digits, dot, hyphen and underscore become underscores, and a name that starts with a digit or symbol is prefixed with an underscore, so First Name becomes First_Name and 2020 becomes _2020.
Are quoted fields with commas handled?
Yes. The parser follows RFC 4180, so a field wrapped in double quotes can hold commas, line breaks and escaped quotes written as two double quotes, all without splitting into extra columns.
Which special characters are escaped?
Ampersand, less-than and greater-than in cell values are escaped to &, < and >. Quotes and apostrophes are left as-is because the values are element text, not attribute values, where those characters are already safe.
Can I rename the root and row wrappers?
Yes. The Root element and Row element fields let you use names like catalog and product instead of root and row. Those names are sanitized to valid XML too, and an empty box falls back to the default.
What happens when a row has fewer cells than the header?
Each missing cell becomes an empty element, such as an opening and closing tag with nothing between them, so every row keeps the same set of child elements as the header.
Does it create attributes or nested elements?
No. The output is deliberately flat: each row is one element and every column is a direct child element holding text. It does not turn dotted headers or repeated values into nested structures or attributes.
Is the XML indented?
Yes. Rows are indented two spaces and their column elements four spaces, with an XML declaration on the first line, so the result is readable and ready to save or paste.
Learn more
- From CSV columns to valid XML element names
The rules XML places on element names, how this tool sanitizes messy headers, and how text values are escaped to keep the document well-formed.
Related tools
CSV to JSON
Convert CSV to JSON online. Turn spreadsheet rows into clean JSON objects or arrays, with smart number and boolean typing. Free tier plus API.
JSON to XML
Convert JSON to XML online. Paste JSON and get clean, indented XML with a custom root element. Special characters are escaped. Runs in your browser.
JSON to CSV
Convert JSON to CSV online. Paste an array of objects and get clean, spreadsheet-ready CSV with the right headers. Runs in your browser.
Air Fryer Converter
Convert any conventional oven recipe to air fryer settings. Lower the temperature by 25 F and cut the cook time by about 20 percent automatically.
Baker's Percentage Calculator
Turn a bread formula into grams with baker's percentages. Flour is 100 percent, enter water, salt and yeast percents to get weights and hydration.
Baking Pan Converter
Swap one baking pan for another and scale the batter to fit. Compares pan areas for round, square and rectangular pans and gives a batter scale factor.