TXT · Text & Data tools

XML to CSV Converter

Input · XML
Output · CSV
0 Bin0 Bout0lines in0keysEmptyXML
Go to the full Data Format Converter

XML to CSV

Convert repeated XML elements to CSV rows. Paste XML on the left; the CSV output builds on the right as you type.

<orders>
  <order><id>1</id><name>Ada Lovelace</name><role>engineer</role></order>
  <order><id>2</id><name>Grace Hopper</name><role>engineer</role></order>
</orders>

becomes

id,name,role
1,Ada Lovelace,engineer
2,Grace Hopper,engineer

XML always parses with its root tag as a wrapper, so <orders> produces { "orders": { "order": [...] } } internally, two levels of wrapping around the actual list. The converter follows that chain automatically: a single key leading to another single key leading to an array counts as “the list,” and each order becomes one row with id, name, and role as columns.

When there’s no list to find

If the XML has no repeated element, there’s nothing to unwrap, and the whole document becomes one row instead, with nested elements flattened into dotted columns exactly like converting a single JSON object to CSV. A warning appears below the output whenever the unwrap step actually finds and uses a nested list, so you can tell which behavior applied.

Attributes become columns

An attribute like <order id="1042"> becomes a column named @_id, since the XML to JSON step that runs first turns every attribute into an @_-prefixed key before the CSV builder sees it.

Multiple nesting levels

Ambiguous documents, where the path to the list passes through an element with more than one child type, don’t unwrap automatically; the converter only follows a chain where each step has exactly one key, so it can’t misidentify a sibling as part of the list. Restructure the XML, or convert to JSON with the XML to JSON converter and edit the shape there before converting to CSV.

Frequently Asked Questions

XML always parses into an object wrapped by its root tag name, so the converter follows a chain of single-key wrappers looking for the first array it finds and uses that as the row list. If your XML has a repeated element several levels deep under single, unambiguous parent tags, this finds it without any configuration.

The whole document becomes a single row, with nested elements flattened into dotted column names, the same as converting a single JSON object to CSV.

They become columns named @_ followed by the attribute name, since attributes turn into ordinary object keys during the XML to JSON step this conversion runs through first.

A nested element inside each row flattens into a dotted column name, the same rule JSON to CSV uses. Turn off Flatten nested to keep that nested structure as a JSON string in one cell instead.

Not directly. The converter always uses the first array it finds while unwrapping single-key XML wrappers. Restructure the source XML, or convert to JSON first and edit the structure there, if a different element should define a row.

Jump straight to a conversion

Full Data Format Converter tool

Explore Our Tools

Browse all tools