XML is a tree; spreadsheets are tables. Whenever XML data has to be sorted, filtered, charted or pasted into Excel, somebody has to flatten the tree — and doing it by hand is where afternoons go to die. This XML to CSV converter does the flattening for you: paste XML and it finds the repeated elements (the records), turns their child elements into columns, includes attributes as columns too (marked with an @ prefix), and produces a standard CSV with a header row, ready to download or copy straight into Excel, Google Sheets or any data tool. The parser is a real XML parser written in JavaScript — it checks that tags match and reports exactly where malformed XML breaks — and it runs entirely in your browser, so even confidential exports never leave your machine. The sample is a three-user directory whose conversion you can inspect line by line below.
How the flattening works
The converter parses your XML into a tree, then looks for the record pattern: the largest group of sibling elements that share the same tag name. In the sample, three <user> elements sit under <users>, so users become the rows. The columns are the union of everything those rows carry: attributes first (here @id — the @ prefix marks an attribute so it can never collide with an element of the same name), then child elements in the order they first appear (name, city, role). If one row is missing a field another row has, its cell is simply empty; if a field repeats inside a row, its values are joined with “; “. Values are escaped to CSV rules: anything containing a comma, a quote or a line break is wrapped in double quotes, and quotes inside are doubled. That is the full, honest rule set — no silent dropping, no guessing.
Worked example
The sample converts to four lines: the header @id,name,city,role and one row per user — 1,Ana Ruiz,Valencia,Designer and so on. Open the downloaded file in a spreadsheet and each value lands in its own cell, because the header and rows follow the same column order and the escaping is standard RFC-style CSV. Try editing the sample before converting: delete the <role> from one user and convert again — that user’s role cell comes out empty, and the column survives because another row still has it. Add an attribute like level="senior" to one user and a new column @level appears for everyone. Those two behaviours — union of columns, empty for missing — are what make the output predictable on real-world irregular XML.
What this converter does not do
CSV is flat, and some XML is not. Deeply nested structures (an order containing items containing components) cannot all live in one table; this tool flattens one level of records and joins deeper text content with spaces, which is a readable summary, not a lossless conversion. If your XML has several different record types side by side, only the most repeated group becomes rows. Mixed content (text woven between elements) is likewise flattened to text. For genuinely relational XML, the right move is one CSV per record type — convert each subtree separately. And while the parser is strict about well-formedness, it does not validate against a schema or DTD: valid-but-unusual documents convert by the same rules as simple ones.
Frequently asked questions
How does it decide what becomes a row?
The largest group of same-named sibling elements in the document. If there is no repeated group, it descends into single-child wrappers until it finds one, so both <users><user/>… and directly repeated roots work.
What happens to attributes?
They become columns named with an @ prefix — id="7" becomes the column @id. That keeps an attribute and a child element that share a name from overwriting each other.
Will it open correctly in Excel?
Yes. The output is standard comma-separated CSV with a header row and RFC-style quoting, which Excel, Google Sheets and LibreOffice all read natively via the download button.
Is there a size limit?
The practical limit is your browser’s memory — files of a few megabytes convert in well under a second. Nothing is uploaded, so there is no server-side cap.
Related tools
Versión en español: Conversor de XML a CSV — Convierte Archivos XML en Filas de Hoja de Cálculo. You may also like: CSV to XML Converter — Turn Spreadsheet Rows into XML Nodes · JSON to XML Converter — Turn JSON Data into Clean XML Online.
Embed this tool on your website — free
Copy the code below to add this working tool to your own page. A small credit link stays with it — that’s all we ask.
