CSV to XML Converter

Modern APIs prefer JSON, but plenty of enterprise systems still expect XML: SOAP services, product feeds for older marketplaces, SEPA payment files, XBRL filings. This converter takes a CSV, lets you name the root element and the per-row item element, and produces a well-formed XML document where each header becomes a child element inside each row. Special characters are escaped and invalid XML tag names are sanitised so the output parses everywhere.

How the XML is generated

  1. 1

    Paste the CSV

    Include a header row so the converter knows what to name each field element.

  2. 2

    Name root and item

    Defaults are `<items>` and `<item>`. Override with anything that starts with a letter or underscore.

  3. 3

    Tag names sanitised

    Non-word characters become underscores; tags that do not start with a letter fall back to a safe default.

  4. 4

    Values escaped

    Ampersands, angle brackets and quotes inside values are replaced with XML entities so the output is always valid.

What the output looks like and where it works

Input CSV

sku,name,price
A-101,Widget,9.99
B-202,Gadget,14.50

Output XML with defaults

<?xml version="1.0" encoding="UTF-8"?>
<items>
  <item>
    <sku>A-101</sku>
    <name>Widget</name>
    <price>9.99</price>
  </item>
  <item>
    <sku>B-202</sku>
    <name>Gadget</name>
    <price>14.50</price>
  </item>
</items>

Tag name rules (XML 1.0)

Allowed Not allowed
Letters, digits, hyphens, underscores, dots Spaces, &, <, >, quotes, parentheses, slashes
Must start with a letter or underscore Cannot start with a digit or punctuation
xml prefix is reserved Tags starting with xml may be rejected

The converter silently replaces illegal characters in header names with underscores. If a header starts with a digit, the whole tag falls back to field_N.

Escape table

Values go through htmlspecialchars with ENT_XML1, so these characters are replaced:

  • &&amp;
  • <&lt;
  • >&gt;
  • "&quot;
  • '&apos;

Common downstream uses

  • Product feeds for older marketplaces or price comparison sites.
  • SOAP request bodies where you need to generate sample payloads from spreadsheet data.
  • XBRL or Dublin Core-style simple schemas that map a flat record to named elements.
  • Android string resources, though you will need to wrap the whole thing in <resources> and rename the item elements to <string name="...">.

Frequently Asked Questions

Non-word characters are replaced with underscores, so Product Name becomes Product_Name. If the sanitised name does not start with a letter or underscore, it falls back to field_N to stay XML-valid.

Not directly, every CSV field becomes a child element inside the item. For attribute-based XML you will need to post-process the output or use a schema-specific tool.

Yes. The output starts with <?xml version="1.0" encoding="UTF-8"?>. Remove it by hand if you are embedding the fragment inside a larger document.

Yes. The CSV you paste is sent to our server, because parsing, escaping and XML assembly run there. It is used only to generate the XML result and is not stored.

Related Tools