CSV to XML Converter

Turn each CSV row into an XML element whose children are named after the header columns.

Loading tool…

About the CSV to XML

The output has one root element (default <root>) containing one element per row (default <row>), with a child element per column. Rename both in the toolbar, e.g. products and product, to match the schema you are feeding.

Header cells are not always valid XML names, so they are made safe: characters other than letters, digits, _, - and . become underscores, and names that start with a digit or with xml get a leading underscore. Unit price becomes <Unit_price> and 2024 becomes <_2024>. Text is escaped, so & and < in data cannot break the document. Empty cells are written as self-closing elements.

If the CSV has no header row, uncheck the option and columns are named col1, col2 and so on. The XML declaration uses UTF-8. Nothing is sent to a server.

Example: the header id,name and the row 1,Ada produce <row><id>1</id><name>Ada</name></row>, indented with two spaces per level so the result is easy to review or diff.

How to use it

  1. Paste CSV or open a file.
  2. Set the root and row element names.
  3. Check the header option and delimiter.
  4. Copy or download the XML.

Frequently asked questions

Can columns become attributes instead of elements?
Name the header column with a leading @, for example @id, and it is written as an attribute of the row element.
What happens to special characters?
&, <, > and " are escaped as entities, so the output is always well-formed XML.
Are numbers typed in XML?
No. XML text has no types; values are written exactly as they appear in the CSV.

Related tools