XML to CSV Converter

Or enter XML manually below
📝

Cleared

Copied

Enter XML in the editor and click 'Convert' to get CSV output.

How XML to CSV Converter Works?

What's a valid XML input for this tool?

This tool accepts XML in two formats:

1. A single element:

<name>Alice</name>

2. A list of items:

<people>
  <person>
    <name>Alice</name>
    <age>30</age>
  </person>
  <person>
    <name>Bob</name>
    <age>25</age>
  </person>
</people>

Each item becomes a row in the CSV. The element names become column headers.

What does the output look like?

The output is a CSV with element names as column headers and each item becomes a row. The result of the above XMLs will be:

Single element output:

name
Alice

List output:

name,age
Alice,30
Bob,25

Note: By default, this tool displays CSV in a table format for easier reading. Click the 'Raw' button to see comma separated values.

What if your XML has empty elements?

If your XML has empty elements, they will be converted to empty values in the CSV.

<person>
  <name>Alice</name>
  <age></age>
</person>

becomes:

name,age
Alice,

What about XML attributes?

If your XML has attributes, they become columns in the CSV. The column name combines the element name and attribute name (e.g., id on <person> becomes person_id).

<people>
  <person id="1" status="active">
    <name>Alice</name>
  </person>
</people>

becomes:

person_id,person_status,name
1,active,Alice