Convert XML to CSV
Flatten any XML
structure.
Free XML to CSV converter. Auto-detects row elements, flattens nested XML with dot notation, handles attributes and namespaces. Upload an XML file or paste directly. Runs entirely in your browser.
Auto-detection, flattening and serialization — three steps under the hood.
CSVShift uses the browser's native DOMParser to parse the XML and then finds the most-repeated child element — the element that will become rows in the CSV. For <products><product>…</product></products>, it detects <product> automatically.
Each row element is recursively flattened. Nested elements become dot-notation column names — <address><city> becomes the column address.city. XML attributes become @attribute columns. Array elements with the same tag get indexed: tag[0], tag[1].
The column set is built as the union of all keys across all rows — so records with optional fields produce empty cells rather than errors. The resulting CSV is RFC 4180 compliant and ready for Excel, Google Sheets or any database import tool.
How nested XML becomes flat CSV columns.
<products>
<product id="1">
<name>Widget Pro</name>
<price currency="USD">9.99</price>
<address>
<city>New York</city>
<country>US</country>
</address>
</product>
</products>
| @id | name | price.@currency | price | address.city | address.country |
|---|---|---|---|---|---|
| 1 | Widget Pro | USD | 9.99 | New York | US |
The structural mismatch between XML and CSV — and how CSVShift handles it.
XML is hierarchical — it supports nested elements, attributes, mixed content (text + child elements) and namespaces. CSV is flat — every row has the same columns, all values are plain strings. Converting between them requires decisions about how to handle depth, attributes and repeated elements.
The trickiest case is repeated child elements with the same tag — for example a product with multiple <image> elements. CSVShift indexes these as image[0], image[1] etc. so all data is preserved in the flat output without losing any records.
Common real-world situations where flattening XML data is necessary.
News aggregators, content tools and SEO platforms export article lists as RSS or Atom XML. Converting to CSV lets you analyse publication dates, titles and URLs in a spreadsheet or import them into a database for tracking.
Legacy enterprise APIs return XML responses. Copying the XML from a SOAP response and pasting into CSVShift converts it to a CSV table — avoiding the need to write an XSLT transformation or a custom parser.
Google Shopping, Amazon and affiliate networks export product catalogs as XML feeds. Converting to CSV lets you audit prices, stock levels and descriptions in Excel — essential for feed optimization and competitive analysis.
Geographic data in KML (Google Earth) and GPX (GPS) formats is XML-based. Converting to CSV extracts coordinates, names and metadata into a spreadsheet or a format ready for GIS tools and mapping applications.
What each setting does and when to change it.
| Option | Values | When to use it |
|---|---|---|
| Flatten depth | 2 · 5 · 10 · Unlimited | 5 levels handles most real-world XML without producing too many columns. Use 2 for shallow XML where deep nesting should stay as a JSON string. Use Unlimited for deeply hierarchical data where every field must be a separate column. |
| XML attributes | Include · Ignore | Include adds attribute values as columns prefixed with @ — e.g. an id attribute becomes @id. Ignore drops all attributes — use when you only need text content and attributes are metadata you do not need in the CSV. |
| Namespaces | Strip · Keep | Strip removes namespace prefixes from element names — g:price becomes price. Recommended for most XML. Keep preserves prefixes — needed when two elements with the same local name but different namespaces must be distinguished. |
Other free converters on CSVShift you might need.
XML parsed natively
in your browser. Always.
CSVShift uses the browser's built-in DOMParser API — the same engine that renders web pages — to parse your XML. No external library is loaded. Your XML file is never transmitted to any server. Paste or upload, and the entire flattening and serialization happens locally in JavaScript.
DOMParser is a W3C standard, available in every modern browser, and handles malformed XML gracefully — reporting parse errors clearly rather than producing silently incorrect output.
<products><product>…</product></products> it detects <product> as the row element. The detected element is shown in the hint above the converter before you click Convert.<address><city>Paris</city></address> becomes the column address.city. Repeated elements with the same tag name are indexed: image[0], image[1]. Set the flatten depth to control how many levels are expanded.import pandas as pd; df = pd.read_xml('file.xml'); df.to_csv('out.csv', index=False). Using xml.etree: parse the tree, iterate over repeating elements, extract text content and write rows with csv.writer. For a no-code browser solution with visual preview, use CSVShift.