Map Extract
Free tool

Convert CSV to XML

Paste a CSV and get well-formed XML: a root element, one element per row and one child element per column, or the values as attributes if you prefer. Header names are turned into valid tag names and special characters are escaped.

Runs in your browser. Nothing you enter is uploaded.

Converting CSV to XML

  1. Paste or open the CSV

    Paste the data or use Open a file. The separator (comma, semicolon, tab or pipe) is detected.

  2. Name the elements

    Set the Root element (default rows) and the Row element (default row). Use names your receiving system expects, such as stockists and stockist.

  3. Choose the options

    First row is a header uses column names as tag names. Write values as attributes puts each value on the row element. Leave out empty cells drops blanks. XML declaration adds the <?xml ...?> line.

  4. Check the element names

    A note lists the tag names made from your headers, so you can see where spaces or leading digits were changed.

  5. Copy or download

    Copy the XML or save data.xml.

Headers that are not valid tag names

XML tag names cannot contain spaces or start with a digit, and CSV headers often do both. Here review count and 1st contact need fixing.

The converter turns them into review_count and _1st_contact, which the element names note shows before you copy anything. The ampersand is escaped, and Oak Lane's empty cells become empty elements. Tick Leave out empty cells to drop them instead.

Input
business,town,review count,1st contact
Kiln & Co Pottery,Frome,48,2026-03-14
Oak Lane Joinery,Frome,,

Root element: stockists   Row element: stockist
Result
<?xml version="1.0" encoding="UTF-8"?>
<stockists>
  <stockist>
    <business>Kiln &amp; Co Pottery</business>
    <town>Frome</town>
    <review_count>48</review_count>
    <_1st_contact>2026-03-14</_1st_contact>
  </stockist>
  <stockist>
    <business>Oak Lane Joinery</business>
    <town>Frome</town>
    <review_count/>
    <_1st_contact/>
  </stockist>
</stockists>

Elements or attributes

StyleOne row looks likeChoose it when
Child elements (default)<stockist><town>Frome</town>...</stockist>The receiving system expects one element per field, or values may be long
Attributes<stockist business="..." town="Frome"/>You want compact output and every value is short

Where XML is still asked for

Most modern tools take CSV or JSON, but XML remains common in older systems and some business integrations: product feeds for marketplaces and comparison sites, accounting and stock software imports, sitemap-like feeds and some public sector data exchanges. If a partner sends you an XML template, match the root and row names to theirs and check whether they want elements or attributes.

The converter produces a flat structure: one level of rows, one level of fields. If the destination needs nested groups, such as an address element containing street and town, build the flat XML here and reshape it in a text editor, or convert to JSON with dotted headers and nest there.

Questions people ask

How do I convert a CSV file to XML?

Paste the CSV, set the names for the root and row elements, and the XML appears with one row element per CSV row and one child element per column. Copy it or download data.xml. Keep the first row as a header so the column names become tag names.

What happens to headers with spaces?

XML tag names cannot contain spaces or most punctuation, so these are replaced with underscores, and names that start with a digit get an underscore in front. The element names note shows the result, so review count becomes review_count and 1st contact becomes _1st_contact.

Can I output the values as attributes?

Yes. Tick Write values as attributes and each row becomes a single element with one attribute per column, such as town="Frome". Attributes suit short values. Leave the option off if values can be long or contain line breaks, which are easier to read as child elements.

Are special characters escaped?

Yes. Ampersands, angle brackets and quote marks are written as XML entities, so a value such as Kiln & Co Pottery appears as Kiln &amp; Co Pottery in the file and as the original text in any XML reader. The output is well-formed and will open in a browser or XML editor.

Where your data goes

XML is generated from your CSV in this browser tab. Nothing is uploaded, and the file you download is created locally.

Checked against the tool on

Top