Back to Tools

CSV to XML Converter

Map CSV rows to XML nodes with custom root/element names

🏷️ Custom Nodes📦 Nested XML
CSV Input

Generate XML from CSV rows

Many older systems, feeds and import wizards still expect XML, while the data you have sits in a spreadsheet. This converter reads pasted CSV and writes an XML document with an XML declaration, a root element, and one element per row. You decide what those elements are called. Conversion is done by JavaScript in the page.

Using the converter

  1. Paste CSV into the CSV Input box, use Paste to bring it from the clipboard, or press Sample to load a list of names, emails and countries.
  2. Choose the Delimiter: comma, semicolon, tab or pipe.
  3. Type a Root Element name (default data) and a Row Element name (default row). Blank fields fall back to those defaults.
  4. Keep First row = Headers ticked to use the first line as tag names. Without it the tags become col1, col2 and so on.
  5. Tick Fields as Attributes if you want each row as a single self-closing tag with attributes instead of child elements.
  6. Press Convert to XML, then Copy or download output.xml.

Two output shapes

By default, a row such as 1,John Doe becomes a row element containing an id element and a name element, each indented on its own line. With Fields as Attributes, the same row becomes one line: the row tag carrying id and name as attributes. The attribute form is shorter and suits flat records; the element form is easier to extend and is what most XML schemas assume.

Typical scenarios

Rules to keep in mind

Values are escaped automatically, so ampersands, angle brackets and double quotes are converted to entities. Header names, however, are used exactly as typed for tag or attribute names. XML names cannot contain spaces or start with a digit, so rename headers such as First Name to FirstName before converting, or the output will not be well-formed. The same applies to the root and row names. Empty cells produce empty elements. Rows shorter than the header list are padded with empty values, and lines that are blank are skipped. Quoted cells are supported as long as they do not span multiple lines.

Related Tools




Frequently Asked Questions

Why is my XML invalid when my headers contain spaces?
The converter uses each header exactly as written for the tag name, and XML names cannot contain spaces. Rename headers before converting, for instance FirstName or first_name, and also avoid starting a name with a digit. The same goes for the root and row names.
What does Fields as Attributes change?
Instead of writing each field as a child element on its own line, it writes one self-closing row tag per record with the fields as attributes. Output is more compact, which suits flat data with short values.
Are special characters like ampersands escaped?
Yes. Values pass through an escaping step that converts ampersand, less-than, greater-than and double quote into their XML entities, so text such as Tom & Jerry will not break the document. Tag and attribute names are not escaped.
Can I change the root and row tag names?
Yes. Enter your own names in Root Element and Row Element. If you leave either field empty, the tool uses data for the root and row for each record, so the output is always valid in structure.
What if my CSV has no header line?
Untick First row = Headers. The tool then treats every line as data and names the fields col1, col2, col3 and so on, so you still get a working XML structure that you can rename later.
Support Chat
We typically reply within minutes

Hello! 👋 Before we start, please tell us your name.