Skip to content

CSV to XML Converter

Convert CSV rows into XML elements named after the column headers, or convert repeated XML records, including attributes, back into CSV.

Runs in your browser Free, no sign-up
Loading tool workspace...

What is CSV to XML Converter?

This CSV to XML converter translates tabular data between CSV and XML. CSV to XML uses the header row as element names and wraps each data row in a <row> element inside a <root> element, with the XML declaration added at the top, so a spreadsheet export becomes a well-structured XML document. Quoted CSV fields and special characters such as & and < are handled, so the output is always well-formed.

XML to CSV does the reverse for record-style XML: it finds the repeated elements, such as <row>, <item> or <record>, and writes one CSV line per record, with child elements and attributes as columns, ready for Excel or Google Sheets.

How to use CSV to XML Converter

  1. Choose CSV → XML or XML → CSV, or click Load Sample to see an example.
  2. Paste your CSV (with a header row) or your XML.
  3. Read the converted output and the row and column count.
  4. Copy or download the result.

Key features

  • CSV to XML and XML to CSV
  • RFC 4180 CSV parsing with automatic delimiter detection
  • Header names converted to valid XML element names
  • Text escaped so the XML is always well-formed
  • Attributes and nested elements become CSV columns
  • Runs entirely in your browser

Common use cases

  • Producing XML imports for ERP, e-commerce and accounting systems
  • Converting XML exports into spreadsheets for analysis
  • Creating XML test data from spreadsheet rows
  • Migrating data between systems that use different formats
  • Preparing product feeds and catalogue files

Technical details & standards

CSV is parsed according to RFC 4180, so quoted fields may contain commas, line breaks and doubled quotes, and the delimiter (comma, semicolon, tab or pipe) is detected automatically. Header names are turned into valid XML names: spaces and other invalid characters become underscores, and a name that starts with a digit or with xml gets a leading underscore, so First Name becomes <First_Name> and 2024 becomes <_2024>. Cell text is escaped (&amp;, &lt;, &gt;) and empty cells become self-closing elements.

XML to CSV parses the document with the browser's DOMParser and picks the largest group of repeated elements under the root as the records. Each record's child elements and attributes become columns, nested elements become dot-separated columns such as address.city, and the column list is the union of all records, so records with missing fields still line up. Values containing commas, quotes or line breaks are quoted in the CSV output.

Frequently asked questions

What XML structure does the converter create from CSV?

A <root> element containing one <row> per CSV line, and inside each row one element per column named after the header, for example <row><id>1</id><name>Ada</name></row>.

How are header names turned into element names?

XML names cannot contain spaces or most punctuation, or start with a digit, so invalid characters become underscores and a leading underscore is added when needed: First Name becomes First_Name and 2024 becomes _2024. Duplicate names get a numeric suffix.

Which XML can be converted to CSV?

Record-style XML with a list of repeated elements, like an export of rows, orders or products. Attributes and child elements of each record become columns, and nested elements become dot-separated columns. Documents with several unrelated lists need a custom transformation.

Can I convert CSV to XML with Excel?

Excel can export XML only through an XML map defined in the Developer tab, which is cumbersome; this converter is quicker for one-off conversions.

Is my data safe?

Processing happens locally in your browser. Tool input is not sent to CodeUnpack servers.

Does it work offline?

Once the page has loaded, this tool can process input without an internet connection.

More converters tools

View all