CSV to XML Converter
Convert CSV to XML - free, no upload.
What this tool does
Paste your CSV, optionally set the root and row element names, and get back valid XML with one element per row and one child element per column.
Converts CSV to XML using the header row as column (element) names.
Lets you set custom names for the root element and each row's wrapping element.
Falls back to generic column names (col1, col2, ...) for any header that isn't a valid XML element name.
Escapes &, < and > in cell values so the output stays well-formed, since values become XML text content rather than attribute values.
Fills a missing cell with an empty element rather than shifting the remaining columns out of position.
How to use it
- Paste your CSV data.
- Optionally set the root and row element names, and whether the first row is a header.
- Copy or download the XML result.
Why use this converter
XML systems expect structured elements, and converting spreadsheet rows by hand is slow. Header names become tags, with root and row names you set.
Why we built it
We built the CSV to XML converter so that you set the root and row element names instead of having them hard-coded. Clean the source with the CSV formatter and compare with the JSON to XML converter.
Related tools worth a look: the XML to CSV Converter and the CSV Column Extractor.
Who this tool is for
- Developers feeding XML systems
- Analysts exporting spreadsheet data
- Students of data formats
When to use it
- Feeding CSV data to an XML system.
- Generating sample XML.
- Creating import files.
- Learning the mapping.
Why invalid column names get replaced instead of breaking the output
Not every CSV header is a legal XML element name.
XML element names can't start with a digit, can't contain spaces, and can't contain most punctuation - but CSV headers routinely do, since spreadsheet column titles are free text. Rather than producing invalid XML that would fail to parse elsewhere, this tool checks every header against the actual XML naming rule and substitutes a generic colN name for any header that doesn't qualify, so the output is always well-formed.
What gets escaped in cell values, and what the input format needs to be
Two details matter for getting clean, valid output: which characters are escaped, and which delimiter the parser expects.
Only &, < and > are escaped
Each CSV cell becomes the text content of an XML element, not an attribute value, so this tool only replaces &, < and > with &, < and >. Double quotes and apostrophes are left exactly as they are, because unlike inside an XML attribute, a literal quote character inside element text doesn't need escaping to stay well-formed. If you were expecting quote-escaping like you'd see in a JSON string or an XML attribute, that's not needed here.
Input is parsed as comma-delimited CSV
The CSV parser this tool uses is always run with a comma delimiter - there's no input-delimiter selector like the CSV formatter tool has. If your source data is tab-separated (TSV) or semicolon-separated, convert it to comma-delimited CSV first (the CSV formatter tool on this site does that) before pasting it in here, or the tab/semicolon characters will be treated as ordinary text inside a single column rather than as column separators.
A missing trailing cell in a row becomes an empty element (e.g. <note></note>) rather than omitting the element entirely, so every row element ends up with the same set of child tags.
What you give it, and what you get back
| Item | Details |
|---|---|
| Input | CSV with a header row. |
| Options | Root and row element names. |
| Output | XML. |
Issues you may run into
| What you see | Why it happens | What to do |
|---|---|---|
| Tags show as col1, col2 | A header is not a valid XML name. | Rename headers without spaces or symbols. |
| Types are lost | All values are text. | Handle types in the consumer. |
| An error message appears | The input is not valid for this format. | Fix the problem the message points to. |
Assumptions and limitations
- Column headers that aren't valid XML element names are replaced with generic names like col1, col2 - the original header text isn't preserved as an attribute.
- All cell values become XML text content as plain strings - there's no attempt to detect or represent numbers or booleans differently.
Frequently asked questions
How do I convert CSV to XML for free?
Paste your CSV and the header row becomes column element names automatically, with one row element per data row.
Can I set my own element names?
Yes - set the root element and row element names in the fields above the input box.
What happens if a column header isn't a valid XML tag name?
It's replaced with a generic name like col1, col2, so the output XML always stays valid.
Does this handle quoted CSV fields with commas inside them?
Yes - it uses a real CSV parser, so quoted commas, quotes and line breaks inside a field are handled correctly.
Does this accept tab-separated (TSV) input?
No - the parser always expects comma-delimited CSV. Convert TSV to CSV first with this site's CSV formatter tool, then paste the result in here.
Do I need to escape quotes in my CSV values?
No - values become XML text content rather than attribute values, so only &, < and > are escaped automatically; double quotes and apostrophes are left as-is.
Is my data uploaded anywhere?
No. Conversion happens entirely in your browser.