XML to CSV Converter
Runs in your browser. Your files are never uploaded.1Add your XML
Drag and drop XML files here
or choose files. You can add several at once.
A small orders file with attributes, nested items, repeated elements, dates and an ID with a leading zero.
2Choose how the CSV should look
Rows and layout
Structure
Values
CSV file
3Check the preview
Choose and rename columns
4Download
Conversion happens on your device. Nothing is sent to a server. CSV and Copy use the table shown in the preview. Need an .xlsx file instead? Use the XML to Excel converter.
The fastest way to convert XML to CSV is to upload your file to the converter above, check the preview, and download the CSV. The tool finds the repeating records in your XML, turns each one into a row, and works entirely in your browser, so your file is never uploaded to a server.
How to convert XML to CSV in 4 steps
- Add your XML. Drag in one or more files, paste the XML, fetch it from a URL, or load the sample file.
- Check which element becomes a row. The tool picks the repeating element for you. If it picked the wrong one, change “Each row comes from”.
- Choose the CSV settings. Pick a delimiter (comma, semicolon, tab or pipe) and an encoding. Keep “UTF-8 with BOM” if you will open the file in Excel.
- Check the preview and download. Rename or remove columns if needed, then click Download CSV.
Need an Excel workbook instead of a CSV file? Use the XML to Excel converter, which also saves .xlsx and .xls files.
XML to CSV example: what you put in and what you get out
This small XML file has two records:
<catalog> <book id="b1"><title>Excel Basics</title><price>19.99</price></book> <book id="b2"><title>Power Query Guide</title><price>29.50</price></book> </catalog>
The converter treats each book as a row, the attribute id becomes the column @id, and each child element becomes a column:
@id,title,price b1,Excel Basics,19.99 b2,Power Query Guide,29.50
How nested XML becomes rows and columns
CSV is a flat format, so nested XML has to be flattened. The Layout setting controls how.
| Layout | What you get | Use it when |
|---|---|---|
| One flat table | One row per record. Repeated child elements are joined into one cell or spread over numbered columns such as item[1], item[2]. | You want a single CSV file and each record is mostly one-to-one. |
| Linked tables | One CSV for each repeating group, connected by row_id and parent_row_id columns. | A record has many child items, such as an order with several order lines. |
| Key / value list | Three columns: record, path and value, with one row for every value in the XML. | The XML is irregular and does not have a clear repeating record. |
With Linked tables you get several CSV files. Use the tabs above the preview to switch between them and download each one.
Which CSV delimiter and encoding should you pick
- Comma: the standard CSV delimiter and the default.
- Semicolon: use it if your computer’s regional settings use a semicolon as the list separator. Excel then opens the file in columns when you double-click it.
- Tab: useful when your values contain many commas and semicolons, or when the next program expects tab-separated data.
- Pipe: a rare delimiter that some import tools and databases expect.
- UTF-8 with BOM: adds a small marker at the start of the file so Excel on Windows reads accented and non-Latin characters correctly. This is the default.
- UTF-8 (no BOM): choose it for databases, scripts and other tools that do not expect the marker.
Options explained
- Each row comes from: the repeating element that becomes one row.
- Include attributes: adds attributes as columns that start with @.
- Remove namespace prefixes: turns ns:price into price.
- Keep text mixed with child tags: stores text that sits next to child tags in a #text column.
- Column names and path separator: short names are used when they are unique; otherwise the full path is used with the separator you pick.
- Trim spaces and remove empty columns: clean up the output before you download it.
- Include a header row: turn it off if the next system expects data only.
- Protect CSV from formula injection: puts an apostrophe in front of text that starts with =, +, – or @ so Excel does not run it as a formula.
- Several files: merge them into the same tables, or keep one set of tables per file. A source file column shows where each row came from.
Common problems when converting XML to CSV
Everything ends up in one row
The wrong element is selected as the row. Open “Each row comes from” and choose the element that repeats, such as order, item or record.
“Not valid XML” error
The message shows the line and column of the first problem. A common cause is a stray ampersand. Click “Try automatic repair” to fix common issues such as unescaped ampersands and invalid control characters.
Too many columns
Repeated elements can create many numbered columns. Set “Repeated elements in a flat table” to “Join into one cell”, or use the Linked tables layout.
The file is very large
The whole file is read into your browser’s memory, so a very large file can fail on a computer with little memory. The preview shows only the first 100 rows to stay fast, but the CSV contains every row. If the file is too big, split it or convert it on a computer with more memory.
Accented characters look wrong in Excel
Choose “UTF-8 with BOM” before you download. Without the marker, Excel on Windows may read a UTF-8 file as a different encoding.
Leading zeros disappear in Excel
The CSV keeps values such as 01234 as text, but Excel turns them into numbers when you double-click the file. Import it with Data, then From Text/CSV, and set that column to Text.
Everything is in one column in Excel
The delimiter does not match your regional list separator. Download the file again with a semicolon, or import it with Data, then From Text/CSV, and choose the delimiter.
Is it safe to convert XML to CSV online
Yes. The conversion runs in your browser with JavaScript. Your XML is not uploaded, and nothing is stored. The one exception is the “From a URL” option, which fetches the XML from the address you type, and only works when that site allows it.
Other ways to open or convert XML
Excel can open XML directly with Data, then Get Data, then From File, then From XML, but the result depends on how your XML is structured. See our guides on how to open an XML file in Excel and how to open an XML file. For an Excel workbook rather than CSV, use the XML to Excel converter.
Limits to know about
- One Excel sheet holds up to 1,048,576 rows and 16,384 columns. The CSV file has no such limit, but Excel cuts off anything beyond it when you open the file. The tool shows a warning when a table is over the limit.
- Files over 200 MB trigger a warning because browsers can run out of memory.
- The XML must be well formed. The automatic repair covers common mistakes only.
- The URL option needs a site that allows cross-origin requests (CORS).
Frequently asked questions
How do I convert XML to CSV?
Upload or paste your XML into the converter at the top of this page, check that the right element is chosen for rows, review the preview, and click Download CSV.
Is my XML file uploaded anywhere?
No. The conversion runs in your browser and your file stays on your device.
How does it handle nested XML?
You can flatten it into one table, split it into linked tables with row_id and parent_row_id columns, or list every value as a record, path and value row. See the table above.
What happens when some records are missing fields?
The tool collects the columns from all records. If a record does not have a field, its cell is left empty. Columns that are empty in every record are removed unless you turn that option off.
Why does my CSV open with garbled characters in Excel?
Excel on Windows may not detect UTF-8 on its own. Download the file with “UTF-8 with BOM” selected so Excel reads the characters correctly.
Which delimiter should I use: comma, semicolon or tab?
Use a comma unless your Excel is set to a regional format that uses a semicolon. Use a tab for tab-separated data. Pipe is available for tools that expect it.
Why does my CSV show only one row?
The converter probably used the root element as the row. Change “Each row comes from” to the element that repeats, such as order or item.
How large a file can I convert?
The limit is your browser’s memory, because the whole file is read at once. The tool warns you above 200 MB. The preview shows the first 100 rows, but the CSV download contains all rows.
Can I convert XML to Excel instead?
Yes. Use the XML to Excel converter to download .xlsx or .xls files.
