Guide

How to Convert XML to CSV or Excel in Seconds

Turn nested XML data into clean rows for spreadsheets. Compare CSV vs Excel output and pick the right one for your workflow.

By Sorawi Tools Team · Published July 10, 2026 · Updated July 24, 2026

Why XML Data Is Hard to Work With

XML stores data inside nested tags that repeat throughout a document. A typical record wraps related facts together: one order element contains a customer element, and that customer contains a name and an email, while the order itself carries a total and an ID stored as an attribute on the opening tag. Real-world exports from CRMs, e-commerce backends, banking systems, and government open-data portals often contain tens of thousands of these records, several levels deep. Reading such a file in a text editor is exhausting, and the data is nearly impossible to sort, filter, or chart while it stays wrapped in tags. Spreadsheets are built for the opposite shape: flat rows and columns, where every row is one record and every column is one field. Converting XML to CSV collapses the hierarchy so that every record becomes one row and every attribute or child element becomes one column. That single transformation unlocks everything a spreadsheet can do, from pivot tables to conditional formatting to quick charts. It is also the standard way to hand data to a colleague who works in Excel or Google Sheets instead of in code. Doing the conversion by hand is painfully tedious: a script that parses the XML, walks the tree, and writes delimited rows runs to hundreds of lines and breaks the moment it meets an unexpected element or a missing field. A converter finishes the same job in seconds and handles the edge cases for you.

When You Would Convert XML to CSV or Excel

You will need this conversion every time structured XML data has to be analyzed, shared, or imported somewhere that expects a table. A common case is e-commerce: many order-management systems export sales as XML, and reconciling thousands of transactions in a spreadsheet is far easier than scrolling through tags. Product catalogs are another classic example. A warehouse system might publish inventory as an XML feed, but building a pricing sheet or a reorder list means turning that feed into rows. Migration projects are a third: when you move data out of a legacy system into a new CRM or database, the source export is often XML and the target import is a CSV template. The same pattern appears in finance (bank statement exports), publishing (syndication feeds), and logistics (shipment tracking data). You should also convert when a non-technical stakeholder needs the data. Sending someone a raw XML file and asking them to read it does not work; sending them a spreadsheet does. One caveat: XML that is genuinely hierarchical, such as a deeply nested product taxonomy, loses some of its structure when flattened. If preserving parent-child relationships matters more than getting a tidy table, think about whether CSV is the right destination before you convert. For the large majority of transactional data, though, flat rows are exactly what you want.

How to Convert XML to CSV or Excel

The XML to CSV converter reads the repeating element structure of your document, maps each record to a row, and turns attributes and child elements into columns. You do not need to know how many fields exist or write any schema; the converter discovers the structure by scanning the file. The output is available as CSV, which opens anywhere, or as Excel (.xlsx), which preserves numeric and date formatting for people who will edit the file in a spreadsheet.

  1. 1Open the XML to CSV converter in your browser
  2. 2Drag and drop your .xml file, or paste its contents into the input box
  3. 3Choose CSV or Excel (.xlsx) as the output format
  4. 4Review the preview rows to confirm the records and columns look right
  5. 5Click download and open the file in Excel, Google Sheets, or your database tool

How Nested XML Gets Flattened Into Columns

Most XML files are nested, and the converter needs a consistent rule for turning a tree into a table. The standard approach is dot notation: a nested element keeps the path to its parent in the column name. An order element containing a customer element containing a name element becomes a column called order.customer.name. This preserves every level of the data in a single row instead of silently dropping information, and it tells you where each value came from. Attributes on elements are handled the same way, so a product element with a category attribute produces a product.@category column. Two things to watch for. First, repeated children: if one record contains multiple line items, the converter must either create several columns (line1, line2, and so on) or several rows. Know which behavior your converter uses and pick the one that matches your analysis. Second, missing fields: when records do not all share the same elements, the union of all columns is used and absent values become empty cells. That is correct behavior, but it means some rows may look sparse. Understanding the dot-notation flattening rule lets you predict the shape of the output before you convert, which saves you from surprises in the preview.

CSV vs Excel Output: Which Should You Pick?

CSV and Excel solve different problems, and the right choice depends on what happens after the conversion. CSV is a plain-text format: one line per row, fields separated by commas and quoted when they contain commas, quotes, or newlines. It is tiny, opens in every tool ever made, and is the format databases and ETL pipelines expect. If you are loading the result into PostgreSQL, BigQuery, or a scripting language, choose CSV. Its weaknesses are also real: it carries no formatting, cannot hold formulas you would type by hand, and a file with more than 1,048,576 rows or 16,384 columns will not open in Excel at all. Excel (.xlsx) is a binary format that stores types, formulas, multiple sheets, and styling. If you are handing the file to a person who will filter, format, and present the data, Excel is the friendlier output because numeric and date columns keep their types and the file opens cleanly with zero encoding surprises. A practical workflow many teams use: export CSV for anything scripted or stored, export Excel for anything that will be read by humans. You can always generate both from the same conversion if your use case is split, and there is no real cost to having a CSV for the database plus an Excel file for the team. Keep the original XML file somewhere safe regardless, because a flattened spreadsheet is a derived artifact, not a replacement for your source of truth.

A Worked Example: Turning Orders XML Into a Sales Table

To make the process concrete, imagine a typical sales export. Your source file wraps a list of orders, and each order element holds an id attribute, a date, a customer child element with name and email children, and a repeated items child containing one line-item element per product. The flattening rule turns that into clear columns. The order id becomes a column holding values like ORD-1042, the date stays a date column, the nested customer values become order.customer.name and order.customer.email, and each repeated item needs a decision: either the converter creates columns such as item_1.name, item_1.price, item_2.name, and item_2.price up to the maximum count seen, or it emits one row per item and repeats the parent fields. Both are legitimate, and which one you want depends on the analysis. If you are building a per-product revenue report, one row per line item is right, because each product gets its own row with the parent order repeated. If you are reconciling orders one at a time, the wide version with item_1, item_2 columns keeps each order on a single row. A converter that shows you the preview makes the difference visible instantly, so you can tell whether the granularity is what you expect before you download. Whatever layout you pick, the same dataset in CSV is dramatically easier to summarize: a pivot table on the product column gives you revenue per product in a few clicks, something you could not do while the data was nested in tags.

Common Mistakes and Pro Tips

The most common failure is assuming every record has the same fields. Real XML exports often skip empty elements, which is fine, but they also occasionally carry different structures in different sections, which produces blank cells or surprising columns. Always scan the preview before downloading. The second classic mistake is an encoding mismatch: XML files marked UTF-8 but actually saved in Latin-1 will show mojibake in Excel. If you see broken accents, re-export the file from the source system as UTF-8 rather than patching it later. Third, be deliberate about record boundaries. If your document has several repeating elements, confirm the converter is treating the one you actually care about as the row unit, or you will get a table of the wrong granularity. Fourth, remember that CSV text is literal: a trailing newline or a BOM character can break the first column header, so if you see a weird character at the start of the file, strip the BOM first. Finally, a few tips that save real time: paste a small sample instead of a huge file when you are just testing the structure, check the first and last rows of the preview to catch truncated exports, and run the conversion on a copy, never on your only copy of the XML.

Frequently Asked Questions About XML to CSV

Will my XML file be uploaded anywhere? No. The conversion runs entirely in your browser, so the file is parsed locally and never sent to a server. That makes the tool safe to use even for exports containing customer names, internal pricing, or financial details. What if my XML has namespaces? Namespace prefixes on tags do not stop the converter from reading the data, and the flattened column names simply follow the element paths you see in the file, prefix included when it is written that way. Do self-closing elements break anything? An element like <discount/> is treated as an empty value, which becomes an empty cell; nothing breaks, and you can spot the pattern in the preview. What happens to very large XML files? The converter streams the document rather than holding it all in memory, so multi-megabyte feeds work fine. The practical limit tends to be the destination format, not the conversion: Excel stops at 1,048,576 rows, so a feed with millions of records should be exported as CSV and analyzed in a database or a tool like DuckDB. Why is my first row missing the header I expected? Some XML exports are wrapped in an envelope element, like a <Response> around the records. The converter normally skips the envelope and flattens the repeating records inside it, but if you see the envelope appearing as a column, check whether your file has records at more than one level. Finally, can I convert the other direction? Yes for practical purposes: keep the original XML as your source of truth, and after flattening, export the spreadsheet back to CSV or Excel whenever a system needs it. The flattened table is a derived artifact, so any re-export should be validated against the original tags before it feeds another system.

XML to CSV Converter

Convert XML data files into CSV tables. Nested elements become columns and repeated elements become rows.

Use the tool