CalcCafe

XML to CSV

Paste XML and instantly get a clean CSV table with one row per repeated record.

Example

Repeated <book> elements become rows; attributes and nested tags become dotted columns:

<library>
 <book id="b1">
  <title>1984</title>
  <price currency="USD">9.50</price>
 </book>
</library>
@id,title,price,price.@currency
b1,1984,9.50,USD

How it works

It parses your XML with the browser's DOMParser, finds the repeating record element, and flattens each record's nested children and attributes into dotted columns. Empty cells are filled and values are quoted/escaped per RFC 4180.

Good to know

This XML to CSV converter turns hierarchical XML into a flat, spreadsheet-ready table entirely in your browser. It scans the root element's direct children, treats the most frequently repeated tag as the "record," and emits one CSV row per occurrence. It's aimed at developers, data analysts, and anyone who needs to pull XML exports (API responses, RSS-style feeds, config dumps, catalog files) into Excel, Google Sheets, or a database import without installing anything or sending data to a server.

Reach for it when you have repeating structured records and need them tabular fast: a list of products, orders, books, or log entries wrapped in a common parent tag. It's less suited to deeply irregular XML where each record has a wildly different shape, because the column set is the union of every key seen across all records, so sparse fields leave many cells empty.

Read the output by its dotted column headers. A bare tag like title is a child element's text; a dot means nesting (author.name); an @ prefix marks an attribute (price.@currency); and a bracketed index like tag[0], tag[1] appears when the same leaf tag repeats inside a single record. Values are quoted and escaped per RFC 4180, so commas, quotes, and newlines inside your data won't break the columns. The status line confirms how many rows were produced, which is a quick sanity check that the right repeating tag was detected.

One practical caveat: detection relies on a tag repeating more than once under the root. If your file has only a single record, or the records aren't direct children of the root (for example they're nested one level deeper), you may get a single wide row or unexpected columns. In those cases, trim the XML so the repeating element sits directly under the document's root, then re-run the conversion.

Frequently asked questions

How does it decide what becomes a row?
It looks at the direct children of the root element and picks the tag that repeats most often as the record. Each occurrence of that tag becomes one CSV row.
How are attributes and nested elements handled?
Attributes are prefixed with @ (e.g. price.@currency) and nested elements use dotted paths (e.g. author.name). Repeated leaf tags within a record get an index like tag[0], tag[1].
Is my data uploaded anywhere?
No — this tool runs entirely in your browser. Your input never leaves your device and it works offline once loaded.
Is it free?
Yes, completely free with no sign-up and no limits.

People also ask

What is the difference between XML and CSV?
XML is a hierarchical, tag-based format that can nest elements and carry attributes, making it good for structured or deeply nested data. CSV is a flat, comma-separated table with rows and columns, which is simpler and directly importable into spreadsheets and many databases.
How do I open the converted CSV in Excel or Google Sheets?
Copy the output and paste it into a sheet, or save it as a .csv file and use File > Open (Excel) or File > Import (Google Sheets). Because values follow RFC 4180 quoting, fields containing commas, quotes, or line breaks stay in their correct columns.
Why does my CSV have empty cells after converting XML?
Columns are the union of every field found across all records, so if one record lacks a tag that others have, that cell is left blank. This keeps every row aligned to the same header set even when records differ slightly in structure.
Can this tool convert XML attributes into columns?
Yes. Attributes are flattened into columns prefixed with an @ sign, such as @id for a record-level attribute or price.@currency for an attribute on a nested element.
What happens to deeply nested XML elements?
Nested elements are flattened into a single row using dotted path names, so author.name represents a name element inside an author element. Each unique path becomes its own column.
Does converting XML to CSV lose any data?
It can lose structural information rather than values. Nesting is preserved only as flattened column names, and very irregular or mixed-content XML may not map cleanly to a flat table, but element text and attributes are carried into cells.
Is it safe to convert sensitive XML files with this tool?
The conversion runs entirely in your browser using the built-in DOMParser, so the XML you paste is never uploaded and works offline once the page has loaded. No data is sent to any server.
How does the tool know which XML element should become a row?
It counts the direct children of the root element and selects the tag name that appears most often as the record type. Every occurrence of that tag is then output as a separate CSV row.

Related tools