XML to CSV
Convert XML files to CSV format.
How to Convert XML to CSV
Paste your XML
Drop an .xml file or paste XML containing repeated records.
Records are flattened locally
Repeated elements are detected as rows and their child values become columns โ in your browser.
Download the CSV
Open the tabular result in Excel or import it into any data tool.
Flattening a tree into rows
XML is hierarchical and CSV is flat, so the first decision is which element becomes a row. An invoice document might yield one row per invoice or one row per line item, and those are different tables answering different questions.
Choosing the repeating element that matches your analysis is the whole job. Everything after it โ which fields become columns, how deeper levels are named โ follows from that choice.
Nested levels and repeated children
Fields nested below the row element become columns with compound names, which works while the nesting is shallow. Repeated children are harder: three addresses under one customer cannot become one row without either three sets of columns or three rows repeating the customer.
Repeating the parent across rows is usually the more useful shape for analysis, at the cost of duplicating the parent's data. It is the same trade a database join makes, and for the same reasons.
Attributes and text together
An element carrying both an attribute and a text value holds two pieces of information that must become two columns. Conversions that take only the text silently drop the attribute, which is a real data loss that produces no error.
Currency codes, units and language markers are the usual casualties, and they are exactly the attributes whose absence makes the numbers meaningless.
Inconsistent records
Optional elements mean different records carry different fields, so the header must cover the union of everything present. Records missing a field leave blanks, and a blank cannot say whether the element was absent or present and empty.
For counting and filtering, that difference frequently matters. If it matters for your analysis, it needs handling before the conversion rather than after.
Escaping on the way out
XML text can legitimately contain commas, quotation marks and line breaks, all of which must be escaped in CSV. A description field with an unescaped comma shifts every subsequent column in that row, and the file still opens โ simply wrong from that point on.
Checking a row containing free text, rather than the first three tidy rows, is the check that catches it.
What CSV cannot keep
Namespaces, schema types, comments, processing instructions and the document's structure all disappear. What remains is the values you selected, arranged as a table โ which is exactly what a spreadsheet or a statistics tool wants, and useless if you needed the structure.
Conversion runs in your browser, so financial and government XML feeds are not uploaded anywhere.
Checking the conversion before trusting it
Count the repeating elements in the source and compare against the data rows in the result. A mismatch means the wrong element was chosen as the row, or that records with a different shape were skipped rather than filled with blanks โ and both look like a perfectly ordinary file afterwards.
Then check one record you can verify by eye, end to end. XML feeds are usually machine-generated and highly uniform, which means an error affects either nothing or everything; a single carefully read row tells you which of the two you have.