XML to CSV

Flatten repeated XML elements into CSV rows.

Open tool

Overview

The XML-to-CSV converter flattens repeated XML elements into CSV rows. Point it at the repeated child element you want to treat as a record, and the tool emits one CSV row per occurrence with one column per leaf field.

Integration engineers consuming SOAP or REST XML responses, data analysts handed an export from a legacy system, and operations staff prepping XML inventories for spreadsheets reach for this when an XML payload needs to live in a column-oriented tool. Long-tail searches that lead here include "convert XML to CSV online", "flatten XML for spreadsheet", and "extract rows from XML to CSV".

How it works

The converter parses the XML using a namespace-aware parser conforming to the W3C XML 1.0 specification. It locates every instance of the chosen record element — typically a child like <book>, <order>, or <customer> that appears repeatedly under a common parent. For each record, it walks the descendant tree and collects leaf text values into fields.

Field names are derived from the path within the record, with dot-separated levels for nested elements (e.g. author.first and author.last for <author><first>...<last>...). XML attributes become fields prefixed with @ (e.g. @id). The output uses RFC 4180 quoting: any field containing a comma, quote, or newline is wrapped in double quotes with embedded quotes doubled.

Examples

  • Flatten a list of <order> elements into a row per order, with columns for id, customer, total, and items count.
  • Convert an XML catalogue of books into a CSV ready for an inventory spreadsheet.
  • Extract repeated <event> records from a calendar feed for analysis.
  • Turn an SOAP response's <row> elements into a normal tabular CSV.

FAQ

What if records have different field sets?
The converter takes the union of every field across all records. Records lacking a particular field get an empty cell in that column.

How are repeated child elements within one record handled?
By default, the converter joins repeated leaves with a separator (; or |) inside a single cell. For one-row-per-leaf output, pick the repeated element as your record selector instead.

Does it support XML namespaces?
Yes. Namespace prefixes are honoured during parsing, and field names follow the local part by default. Provide an explicit selector path when you need to disambiguate.

What about mixed content (text plus child elements)?
Mixed content is awkward to flatten; the converter takes the concatenated text content of the element as its value and surfaces children as separate fields. Pure mixed-content XML is best transformed with XSLT first.

Are attribute values quoted differently than element content?
No. Attribute and element values both follow standard CSV quoting rules. The @ prefix in the column name is the only marker that the source was an attribute.

Try XML to CSV

An unhandled error has occurred. Reload ×