Skip to content

XML to CSV converter

XML to CSV uses row detection plus flattening, so repeated elements become table rows and hierarchical XML becomes delimited columns.

  • Converted with Table engine · nothing stored
  • Free: 5 conversions a day · 5 MB each
  • Higher limits →

From real runs

What you get — and what changes

  • Row detection Changed

    Without rowPath, the parser chose the repeated product elements and warned that XML rows were detected with a heuristic.

  • Attributes Changed

    Attributes became columns prefixed with @_, including @_id and @_active in the CSV header.

  • Nested child elements Changed

    The price element with text and currency attribute flattened into price.#text and price.@_currency columns.

  • Repeated children Changed

    Two tag elements for Hoodie became a JSON string inside one CSV field rather than duplicate CSV rows.

  • Scalar values Kept

    Product names, numeric price text, currency codes, ids, and active flags were all present in the CSV rows.

  • Document wrapper Lost

    The catalog root and generated attribute were not emitted as row values because the detected rows were product elements.

  • XML ordering Lost

    Original element order, indentation, comments, and mixed-content boundaries are not recoverable from the flattened CSV.

Sample conversions

Catalog products

Input
359-byte XML catalog with generated attribute, two product elements, nested price currency attributes, and repeated tag elements.
Output
139-byte CSV header was name,price.#text,price.@_currency,tag,@_id,@_active and first row included Hoodie,49.95,USD,"[""outerwear"",""fall""]",p-100,true.

Single repeated tag

Input
Second product had one tag element with value ceramic and active=false.
Output
The CSV wrote Mug,12.5,USD,ceramic,p-200,false, so single repeated-field values are not wrapped as arrays.

A real XML → CSV run

We converted our XML sample (733 B) with Table engine on 2026-09-11. It took 1 ms and produced a 225 B CSV file, 69% smaller than the input. The engine raised 1 warning, listed below.

Input · sample.xml · 733 B

25 elements, root <rows>, XML declaration present

Elements
25
Root element
rows
XML declaration
yes

Output · sample.csv · 225 B

4 data rows × 5 columns; header: company,stage,arr,owner,close_date

Rows
4
Columns
5
Header
company,stage,arr,owner,close_date
  • XML rows were detected with a heuristic; pass rowPath for deterministic parsing.

First lines of the output

csv
company,stage,arr,owner,close_date
Northwind Traders,Proposal,48000,R. Ayers,2026-10-14
Contoso Ltd,Negotiation,120000,P. Ng,2026-09-30
Fabrikam,Qualified,22500,R. Ayers,2026-11-02
Tailspin Toys,Won,64000,M. Okafor,2026-09-03

Options and when to change them

rowPath
Set the path to the repeated element, such as catalog.product, when automatic row detection might pick the wrong list.
flattenSeparator
Change the dot separator if downstream column names cannot contain periods.
arrayMode
Use JSON mode for variable repeated children, or explode mode when each repeated child should get an indexed column.
delimiter
Choose tab or semicolon output for importers that cannot accept comma-delimited CSV.

Do it yourself

Python ElementTree

bash
python - <<'PY'
import csv, xml.etree.ElementTree as ET
root = ET.parse("in.xml").getroot()
with open("out.csv", "w", newline="", encoding="utf-8") as fh:
    w = csv.writer(fh)
    w.writerow(["id", "active", "name", "price"])
    for p in root.findall("product"):
        w.writerow([p.get("id"), p.get("active"), p.findtext("name"), p.findtext("price")])
PY

This is deterministic because the row path is coded by hand; change it for your XML shape.

XML to CSV by API or MCP

The HTTP API and the MCP server run the exact engine this page uses (Table engine); the response carries the same warnings the web converter shows. Check support first with GET /api/v1/pairs?from=xml&to=csv.

curl
curl -X POST https://filetypeconverters.com/api/v1/convert \
  -H "Authorization: Bearer $FTC_API_KEY" \
  -F "file=@input.xml" -F "from=xml" -F "to=csv" \
  -F 'options={"encoding":"utf-8"}' \
  --output output.csv

Options this engine accepts for XML → CSV

KeyApplies toTypeDefault
encodingReading XMLutf-8 · latin1utf-8
flattenSeparatorReading XMLstring.
arrayModeReading XMLjson · explodejson
rowPathReading XMLstring
delimiterWriting CSVstring,
newlineWriting CSV ·
API reference

When this is the wrong conversion

  • Use /convert/xml-to-json when attributes, nesting, and repeated elements matter more than spreadsheet columns.
  • Do not use CSV if mixed-content XML order or comments carry meaning; keep XML and parse it with an XML-aware tool.

XML to CSV questions

How does XML to CSV choose rows?

If rowPath is not supplied, the parser looks for the largest repeated array of object-like elements. In our catalog test it picked product elements and warned that the choice was heuristic.

Where do XML attributes go in CSV?

Attributes become regular columns with an @_ prefix. The product id and active attributes became @_id and @_active columns.

What happens to repeated child tags?

Variable repeated children are flattened into a cell value. In JSON array mode, two tag nodes became a quoted JSON array inside the CSV field.