Skip to main content

XML to CSV

Convert XML to CSV in your browser. Finds the repeating record element automatically, flattens nested elements and attributes into columns.

All Data tools →

This tool runs entirely in your browser. Nothing you enter is sent to our servers, so there is nothing for us to store or see.

About the XML to CSV

Paste XML and get CSV back as you type. Everything runs inside this page on your own device, so an export containing real data is never uploaded.

The first problem is working out what a row even is. XML has no notion of rows — it is a tree, and the rows are wherever an element repeats. So the document is examined for the shallowest element that has two or more children sharing a name, and those become the records. In an ordinary export that finds <row>, <record> or <item> without being told; in an RSS feed it finds <item> inside <channel>, past two levels of wrapper.

The second problem is nesting. A record whose fields are themselves elements is flattened into dotted columns, so <author><name>Ada</name></author> becomes a column called author.name. Attributes become columns too, prefixed with @ so an attribute and a child element of the same name cannot collide. Where the same element repeats inside one record, the second and later ones are suffixed rather than allowed to overwrite the first — that is how a list of tags survives instead of being reduced to its last entry.

The columns are the union of every field across every record, in the order first seen, so a field present on only one record still gets a column and the records that lack it get an empty cell rather than being shifted sideways.

How to use the XML to CSV

  1. Paste your XML

    Paste into the left pane, or drop a .xml file onto it — dropping reads the file locally and never uploads it.

  2. Check what it found

    The status line names the record element it detected and how many it found. If that is not what you expected, the document probably nests differently than you think.

  3. Choose how to flatten

    Leave flattening on to turn nested elements into dotted columns. Turn it off to keep each nested element as its combined text in one cell.

  4. Copy or download

    The CSV appears on the right as you type. Copy it, or download it as a .csv file.

Frequently asked questions

Is my data uploaded anywhere?

No. The conversion runs inside your browser and nothing is sent to a server. You can disconnect from the internet once the page has loaded and it will keep working exactly as before.

How does it know which element is a row?

It looks for the shallowest element that has two or more children sharing a name, and treats those as the records. That finds row, record or item in an ordinary export without being told, and finds item inside channel in an RSS feed even though it sits two levels down.

What happens to attributes?

They become columns prefixed with @, so an id attribute becomes a column called @id. The prefix is there so an attribute and a child element with the same name cannot collide and silently overwrite one another, which is common in real XML.

How are nested elements handled?

With flattening on they become dotted column names, so author/name becomes author.name. With it off, the nested element contributes all of its combined text in a single cell. Flattening is on by default because dotted columns are what make the result usable in a spreadsheet.

What if the same element appears twice in one record?

The second and later ones are suffixed — tag, tag_2, tag_3. A CSV column can hold one value per row, so without this a list of three tags would be reduced to whichever happened to come last, losing two of them with no indication.

What if my XML is invalid?

You get a message naming the problem — a mismatched closing tag, or a document that ends while a tag is still open — and no output. Pasting something incomplete mid-edit simply shows that message until the document is well-formed again.