Skip to content
ZeroServer.tools

XML to CSV

Flatten repeated XML records into CSV rows.

or drop a file here
CSV Output

Converted to 2 CSV rows.

Flattening XML into CSV

This tool parses your XML and treats the repeated child elements of the root as rows, with each record's leaf tags becoming columns. Attributes become columns too— a record's own attributes appear as @name and a field's as field@name — so attribute-only rows such as <row id="1" name="Ada"/> export correctly instead of being rejected. The header is the union of every field name encountered, and values containing commas, quotes, or newlines are escaped per RFC 4180. Records with no wrapper element work as well, so you can paste a fragment. Parsing runs entirely in your browser using a lightweight tokenizer — no data is uploaded.

Built and maintained by Meet Shah · Last updated

What this tool is used for

  • Flattening a repeated XML record set into a spreadsheet.
  • Extracting a table from an XML feed or an export.
  • Producing a CSV from a SOAP response for analysis.
  • Converting an XML data file for a tool that only reads CSV.
  • Getting tabular data out of a config or a report in XML.

Frequently Asked Questions

How does hierarchical XML become flat rows?
By choosing a repeating element as the row and flattening everything beneath it into columns, with nested paths joined into column names. The choice of which element is the row is the whole conversion — pick the wrong one and you get either one row or thousands.
What happens to attributes?
They become columns alongside the child elements, usually distinguished by a prefix such as `@id`. XML draws a distinction between an attribute and a child element that CSV cannot represent, so a document using both for the same kind of data produces confusing column names.
How are repeated child elements handled?
Badly, inherently — CSV has no way to hold a list in a cell. The options are joining with a separator, numbering the columns, or emitting one row per child and duplicating the parent's values. Each loses something, which is why deeply repeated structures resist flattening.
Are namespaces preserved?
Typically stripped, because a prefixed name like `ns:element` is awkward as a column header and the prefix is not the identity anyway — the namespace URI is. If two namespaces use the same local name, stripping them collides two different fields into one column.
Why does the encoding matter more for XML?
Because an XML declaration states its encoding and a CSV does not. A UTF-8 XML converted to CSV and opened in Excel shows mojibake unless a byte-order mark is added, since Excel assumes the system codepage — the declaration that made XML unambiguous has nowhere to go.

Common errors and gotchas

  • Choosing the wrong repeating element, which produces one row for the whole document or one per field.
  • Losing attributes, which carry data as often as element text does.
  • Flattening nested elements inconsistently, so columns appear and disappear between rows.
  • Ignoring namespaces, which can make the repeating element impossible to select.
  • Forgetting to quote values containing commas, which breaks the CSV.

Related Converters tools

Private & free — this tool runs entirely in your browser.

IndieKitShip your Next.js startup in days.affiliate