To convert XML to CSV in Excel, flatten each repeated XML record into a CSV row, verify the export, and import the UTF-8 file with deliberate column types. The XML to CSV Converter handles the XML-to-CSV part locally in your browser without uploading the document; Excel remains the application used to open or import the resulting table and control how cell values are interpreted.
This workflow works well for predictable XML collections such as a product catalog containing repeated product elements with scalar child fields. It is not a general-purpose XML-to-Excel transformation: the converter produces CSV rather than an .xlsx workbook, and you must identify the record element explicitly.

What becomes a row and a column
The converter uses the named repeating element as the row boundary. Record attributes and direct child elements become separate columns, while later fields that were absent from the first record are appended to the header.
| XML construct | CSV result | Excel implication |
|---|---|---|
| Matching record element | One row for each matching element | The row count should match the selected source records |
| Record attribute | A column prefixed with @, such as @id | The prefix distinguishes attributes from child elements with the same name |
| Direct child element | A column named with its exact qualified name | Its trimmed text content supplies the cell value |
| Repeated direct child name | A compact JSON array in one CSV cell | All values remain in one field rather than becoming separate rows |
| Non-whitespace text outside child elements | A #text column | Whitespace-only text does not create this column |
| Missing field in a record | An empty field | Rows retain the same rectangular column set |
| Nested markup inside a direct child | Descendant text flattened into that child’s column | Nested structure and child attributes are not preserved |
Column order is deterministic: fields found in the first record appear first, and previously unseen fields from later records are appended. The CSV begins with a header built from that union. Spaces are preserved by the CSV serialization, although direct-child text itself is trimmed. Fields containing commas, quotes, tabs, or line breaks are quoted according to the RFC 4180 CSV format, and records use CRLF row endings.
Convert the XML into a CSV file
- Check that the source XML is well formed. Open the XML in a text editor and confirm that tags, attribute quotes, and entity references are balanced. Malformed tags, quotes, or entities cause the browser parser to return an error document and block conversion. A DOCTYPE declaration is rejected before parsing, so remove it only through a trusted transformation that preserves the document’s meaning; the converter does not process external entities, DTD defaults, or custom entity definitions.
- Identify the exact repeating record element. Look for the element that occurs once per logical record and whose children contain the fields you want in columns. Enter its exact qualified name, such as item or ns:item. Matching is case-sensitive, so preserve the spelling and namespace prefix exactly as written. The converter does not automatically infer the record element, evaluate XPath, or normalize namespaces.
- Paste the XML and review formula protection. Enter the qualified record name in the converter’s record-name field and paste the complete XML document. Leave formula protection enabled when people will open the CSV directly in Excel. It is enabled by default and protects values that begin with formula-like characters.
- Convert and reconcile the table structure. Run the conversion, then confirm that every matching record appears in the output and that the header contains the union of expected attributes and direct-child fields. Check that attribute columns start with @ and that fields missing from particular records are empty rather than shifted into neighboring columns.
- Copy or download the CSV, then inspect sensitive rows. The download is UTF-8 text/csv without a byte-order mark. Review repeated-child cells, which contain compact JSON arrays, and inspect numbers, dates, identifiers, leading-zero values, and Booleans before comparing representative rows with the source XML.
Import the CSV into Excel
Importing the CSV gives you more control than simply double-clicking the file, especially when identifiers contain leading zeros or values need to retain exact text.
- Save the downloaded file with a .csv extension. If you copied the CSV instead of downloading it, paste it into a plain-text editor and save it as UTF-8 before importing. Some legacy spreadsheet configurations require an import wizard or an explicit UTF-8 selection.
- Use Excel’s text or CSV import command. In current desktop versions, select Data > From Text/CSV. If your version presents the full data menu, use Get Data > From File > From Text/CSV and select the saved file.
- Set UTF-8 as the source and comma as the delimiter. Let Excel honor quoted fields rather than treating every comma as a separate break. This matters when an XML text value contains a comma, quotation mark, tab, or line ending.
- Choose column types in the import preview. Set identifier, account, postal-code, and other leading-zero columns to Text. Select Number or Date only when that interpretation matches the source contract, especially for long values where numeric rounding could occur. The converter preserves XML values as text spellings, but Excel may otherwise guess their types when the file is opened.
- Load the data and compare it with the source. After loading, check the worksheet’s row and column counts against the source records and inspect the first, middle, and last rows. If you opened the file directly rather than using the preview, review leading zeros, long numbers, dates, Booleans, and formula-like values manually.
Protect formula-like cells
Spreadsheet programs may interpret cells beginning with =, +, -, or @ as formulas. With protection enabled, the converter prefixes those values with a tab inside a quoted CSV field. This is an Excel-oriented mitigation based on OWASP CSV Injection guidance.
The tab prefix intentionally changes the cell data and is not universally safe for every spreadsheet or programmatic importer. Keep protection enabled for a CSV that people will open and use in Excel, then verify how the values appear after import. Disable it only when you require exact raw values and the destination treats every cell as inert text. Disabling protection for a human-opened spreadsheet can restore the original value while also restoring the possibility of accidental formula execution.
Check limits and errors before using the export
The converter fails rather than silently truncating an oversized result. Its verified boundaries and error conditions are:
| Condition | Verified behavior | Practical response |
|---|---|---|
| Malformed XML | An error document blocks conversion | Correct the tags, quotes, or entity references and retry |
| DOCTYPE declaration | Rejected before parsing | Use a trusted DTD-free transformation or an application-specific parser |
| No matching record name | A no-match error is reported | Check the element spelling, prefix, and case |
| XML input | Maximum of 500,000 XML characters | Transform or divide the source into smaller record collections |
| Matching records | Maximum of 10,000 matching records | Split the collection or use a streaming application workflow |
| Columns | Maximum of 200 columns | Reduce the selected fields or transform the record shape |
| CSV output | Maximum of 5,000,000 CSV characters | Convert a smaller subset rather than expecting truncation |
Before replacing a production export, compare the source record count with the converted table, confirm the column union, and inspect representative values for quoting, Unicode, repeated children, and type-sensitive fields. A correct column count alone does not prove that every value landed in the intended column, so row-level sampling remains important.
Know when the XML needs a custom transformation
XML has no universal record-to-table mapping. This converter is intended for predictable feeds in which repeated records contain scalar child text. It does not expand nested arrays into multiple rows, join parent values, preserve schema types, validate against an XSD, or handle arbitrary mixed-content documents without loss.
Nested markup is flattened to descendant text, so element boundaries, child attributes, comments, processing instructions, structural namespace prefixes, and mixed-content ordering are not retained. When the same direct-child name occurs more than once in a record, its values are placed in a compact JSON array within one cell. For a deeper look at that specific representation, see how to convert XML to CSV without losing repeated fields.
If downstream work depends on nested hierarchy, precise namespaces, DTD semantics, custom types, or one-to-many relationships, use an explicit XSLT transformation or application code and define the required output contract. The same applies when a CSV table is only an intermediate format and the final deliverable must be a formatted multi-sheet .xlsx workbook.
For a deeper look, see Is an XML to JSON Converter Safe to Use Online?.