CSV to XML Converter

Convert CSV to XML - free, no upload.

CSV to XML converter
XML result

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

  1. Paste your CSV data.
  2. Optionally set the root and row element names, and whether the first row is a header.
  3. 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 &amp;, &lt; and &gt;. 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

Input and output of CSV to XML Converter
ItemDetails
InputCSV with a header row.
OptionsRoot and row element names.
OutputXML.

Issues you may run into

Common problems with CSV to XML Converter
What you seeWhy it happensWhat to do
Tags show as col1, col2A header is not a valid XML name.Rename headers without spaces or symbols.
Types are lostAll values are text.Handle types in the consumer.
An error message appearsThe input is not valid for this format.Fix the problem the message points to.

Assumptions and limitations

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.

Dev ToolsCSV Formatter & CSV to TSV ConverterParses your data with a real RFC-4180-aware parser - so quoted fields containing commas, quotes or line breaks are handled correctly - then re-serialises it cleanly with consistent line endings and only the quoting that's actually needed.Dev ToolsJSON to XML ConverterUses one clear, disclosed convention in both directions: a JSON key becomes an XML element, arrays repeat that element, and an object key starting with @ becomes an XML attribute instead - since JSON and XML don't map onto each other in only one correct way.Dev ToolsCSV Column ExtractorReads the actual header row from your CSV and shows a checkbox for every column found, so you pick by name rather than guessing column numbers - and the remaining columns keep their original left-to-right order.Dev ToolsCSV Duplicate RemoverCompares the full row across every column - not just one key field - and keeps the first occurrence of each unique row, with optional case-insensitive and whitespace-trimmed matching for messy exports.Dev ToolsJSON to CSV ConverterHandles the common case cleanly: a JSON array of flat objects becomes a CSV with a header row built from every key seen across all objects, and CSV converts back to an array of objects using the header row as field names.Dev ToolsXML to CSV ConverterScoped to the common repeated-row shape - one root element containing repeated row elements, each with simple child elements as columns - which is exactly what this site's own CSV-to-XML tool produces, and what most row-oriented XML exports look like.