CSV to XML Converter
Turn a CSV export into XML: each row becomes a record element, each column a child element named after its header — with the delimiter detected for you and header names made XML-safe.
CSV to XML Converter
Runs in your browser — nothing you enter is uploaded or stored.
Scratchpad auto-saved
How it works — in four simple steps
No signup and nothing to install — it all runs in your browser.
Add your CSV
Paste it into the left box, press Open file, or drag a .csv file onto it. Sample loads a realistic example.
Set the options
Adjust the options above the boxes — the output updates instantly as you change them.
Check the result
Read the status line: it reports rows, keys and any value that couldn't be represented in XML.
Copy or download
Copy the XML or download it as a .xml file. Nothing was uploaded at any point.
Rename a header to start with @ (like @sku) and that column becomes an attribute on each record element.
Features
Delimiter auto-detection
Comma, semicolon, tab or pipe is sniffed from the first lines — European Excel exports with ; just work.
Header row or not
Use the first row as field names, or treat every row as data with generated column1, column2… names.
Rebuild nested objects
Headers like address.city can be folded back into nested objects instead of flat dotted keys.
Your element names
Set the root element and the name used for each array item, and invalid characters are fixed for you so the XML stays well-formed.
Attributes kept, clearly marked
XML attributes become keys with an @ prefix (or _ / - / none), so they never collide with child elements of the same name.
Declaration on demand
Include or omit the <?xml version="1.0" encoding="UTF-8"?> line.
Private by design
Parsing and conversion run in your browser with JavaScript — your data is never uploaded, logged or stored.
About the CSV to XML Converter
CSV is a flat grid and XML is a tree, so converting CSV to XML means wrapping the grid in two levels of elements: a root for the whole file and a record element for each row. Inside each record, every column becomes a child element named after its header, so a row Ada,London under the headers name,city becomes <row><name>Ada</name><city>London</city></row>.
The CSV is parsed by an RFC 4180 parser, so quoted fields with commas, doubled quotes and line breaks inside cells come through intact. The delimiter is detected from the first lines (comma, semicolon, tab or pipe), which matters for files saved by European versions of Excel. Header names are cleaned into legal XML names: spaces and symbols become underscores and a name that starts with a digit gets a leading underscore — Unit price (€) becomes Unit_price rather than breaking the document.
Want a column as an attribute instead of a child element? Rename its header to start with @ (for example @id) and it's written as <row id="…">. Headers with dots, like address.city, can be nested into sub-elements with the Nest dotted headers option.
Examples
A small product export with a header that isn't a legal XML name, a price column and a quoted description containing a comma.
@sku,name,Unit price,stock,description
TF-MUG,Feather mug,12.50,40,"Ceramic, 350 ml"
TF-TEE,Logo tee,19.00,12,"Organic cotton, unisex"
TF-CAP,Cap,15.00,0,Adjustable strap<?xml version="1.0" encoding="UTF-8"?>
<products>
<product sku="TF-MUG">
<name>Feather mug</name>
<Unit_price>12.50</Unit_price>
<stock>40</stock>
<description>Ceramic, 350 ml</description>
</product>
<product sku="TF-TEE">
<name>Logo tee</name>
<Unit_price>19.00</Unit_price>
<stock>12</stock>
<description>Organic cotton, unisex</description>
</product>
<product sku="TF-CAP">
<name>Cap</name>
<Unit_price>15.00</Unit_price>
<stock>0</stock>
<description>Adjustable strap</description>
</product>
</products>This output was produced by the converter on this page with root products and item product — load it with the “Product feed” preset above and change any option to see the effect.
How CSV maps to XML
| In CSV | Becomes in XML |
|---|---|
| The whole file | one root element (default <rows>) |
| Each data row | a record element (default <row>) |
Header city, value Pune | <city>Pune</city> |
Header @id | attribute id="…" on the record |
Header address.city + Nest option | <address><city>…</city></address> |
Header Unit price | <Unit_price> (legal XML name) |
| Empty cell | empty element <city/> |
"Smith & Co" | Smith & Co |
Things that trip people up
- Excel's semicolons. Excel in much of Europe saves “CSV” with semicolons because the comma is the decimal separator. Auto-detect handles it; choose the delimiter manually if a file has very few rows.
- Duplicate headers. Two columns named
phoneproduce two<phone>elements in each record, which is valid XML but may confuse a consumer expecting one. Rename them first. - Garbled accents. If é shows as é, the file wasn't UTF-8. Re-save it from Excel as “CSV UTF-8 (Comma delimited)” and open it again.
- Rows of different lengths. Missing trailing cells become empty elements and extra cells beyond the last header are ignored, so check the table preview for rows that shifted.
CSV vs XML at a glance
| Property | CSV | XML |
|---|---|---|
| Specification | RFC 4180 (2005) | XML 1.0 Fifth Edition (W3C, 2008) |
| File extension | .csv | .xml |
| Media type | text/csv | application/xml (RFC 7303) |
| Data types | text only — every cell is a string | text only (types come from a schema) |
| Comments | No | Yes <!-- --> |
| Nesting | None (flat rows) | Unlimited |
- CSV: Fields containing a comma, a double quote or a line break must be wrapped in double quotes, and a quote inside is written twice ("").
- XML: A document has exactly one root element; element names can't start with a digit, and only five entities (& < > " ') are predefined.