CSV to XML converter

Convert CSV rows into well-formed XML in your browser. Choose child elements or attributes. Nothing is uploaded.

About this converter

This conversion almost always exists because something downstream will only accept XML: a product feed, a bank import format, an ERP, a government filing. Your data is in a spreadsheet, the specification wants a document, and the gap between them is exactly one conversion.

Each CSV row becomes a row element inside a rows container. You choose whether the cells become child elements or attributes on the row, because specifications differ and neither is more correct than the other. Attributes produce a much smaller file; child elements are easier to read and can hold values containing newlines.

Column headers become element or attribute names, which means they have to satisfy XML naming rules that CSV headers routinely violate. A header like "Unit Price (GBP)" cannot be an element name, so punctuation and spaces are rewritten to underscores, and a header starting with a digit gets an underscore prefix. Empty headers become column_1, column_2 and so on rather than producing an invalid document.

Values are entity-escaped - ampersands, angle brackets and quotes - which is what stops a product name like "Smith & Sons" from breaking the file. That single missing escape is the most common reason a hand-built XML feed gets rejected.

If your CSV has no header row, switch the header option off and the columns are named positionally. If your file came out of Excel in a European locale it is probably semicolon-delimited, and there is an option for that too.

The whole conversion runs in your browser. Nothing is uploaded, so a price list or customer file stays on your machine.

Frequently asked questions

Child elements or attributes - which should I use?
Whatever the receiving specification says. If you have a choice: attributes give a smaller file, child elements are more readable and can contain multi-line values.
Why was my column header renamed?
XML names cannot contain spaces or most punctuation and cannot start with a digit. Those characters are rewritten so the document is well-formed.
Can I change the rows and row element names?
Not yet - find and replace them once in your editor. They are the only two fixed names in the output.

Related converters