CSV to XML Converter
Map CSV rows to XML nodes with custom root/element names
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
- 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.
- Choose the Delimiter: comma, semicolon, tab or pipe.
- Type a Root Element name (default data) and a Row Element name (default row). Blank fields fall back to those defaults.
- Keep First row = Headers ticked to use the first line as tag names. Without it the tags become col1, col2 and so on.
- Tick Fields as Attributes if you want each row as a single self-closing tag with attributes instead of child elements.
- 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
- Preparing a product or catalogue feed for a system that only accepts XML.
- Creating test fixtures for an XML parser from a spreadsheet of sample values.
- Building a quick configuration or lookup file from a list maintained in Excel.
- Learning how flat tabular data maps onto a tree structure.
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