XML to CSV Converter — Free Online Tool
Convert XML to CSV format online. Extracts repeated elements as rows. Free, browser-based.
Converting XML to CSV is useful for importing XML data exports into spreadsheets or databases. This tool parses an XML document using the browser's DOMParser, identifies the repeated element (the most common child of the root), and extracts its child elements as CSV columns. This works well for XML exports from databases or ERP systems where the structure is a list of records.
How to use
- Paste your XML document into the input textarea.
- Click 'Convert to CSV' to extract the data as CSV rows.
- Copy the CSV to clipboard or download it as a .csv file.
FAQ
What XML structure is required for conversion?
The tool works best with XML that represents a list of records — a root element containing multiple repeated child elements of the same type, each with the same child elements as columns. For example: <records><record><name>Alice</name><age>30</age></record><record>...</record></records>. The tool identifies the first repeated element as the row type and uses its child element names as CSV column headers.
How are XML attributes handled?
XML attributes on the record elements are included as CSV columns, with the column name being the attribute name. Both child element content and attribute values from the same record element are included in the same CSV row.
What happens with nested XML elements?
The converter extracts only the direct children of each record element. If a child element itself contains further nested elements, its text content (the concatenated text of all its descendants) is used as the cell value. Deep nesting is not fully supported — for complex nested XML, consider using the XML to JSON converter first and then processing the JSON.
Can I convert an XML file with a single record?
Yes, but the output will have only one data row (plus the header row). The tool identifies the record type from the most common repeated child element. A single-record XML will still produce valid CSV output.
How are XML special characters in text content handled?
XML entity references (<, >, &, ', ") are automatically decoded by the DOMParser before the text is placed in the CSV output. So & in XML becomes & in the CSV, which is the correct behaviour.
Is the conversion done in my browser or on a server?
The conversion runs entirely in your browser using the built-in DOMParser API and PapaParse. No data is sent to any server.