XML → CSV Converter
Convert XML to CSV locally. The root must contain repeating elements; attributes are flattened to columns.
Required XML structure
CSV is a flat, tabular format. The converter routes through JSON as an intermediate step, so it expects your XML to have a repeating element pattern — a root element containing multiple sibling elements of the same tag, each with the same set of child elements. Those child element names become CSV column headers.
Input
<?xml version="1.0"?>
<users>
<user>
<id>1</id>
<name>Alice</name>
<city>Paris</city>
</user>
<user>
<id>2</id>
<name>Bob</name>
<city>London</city>
</user>
</users>Output
id,name,city 1,Alice,Paris 2,Bob,London
Attribute handling
XML attributes on row elements are flattened into CSV columns alongside child element values. If both an attribute and a child element share the same name, the child element value is used.
Input
<products>
<product id="p1" category="books">
<name>TypeScript Deep Dive</name>
<price>29.99</price>
</product>
</products>Output
id,category,name,price p1,books,TypeScript Deep Dive,29.99
Warning: Deeply nested XML (elements inside elements) cannot be represented as flat CSV columns. Nested child elements will be serialised as JSON strings in the CSV cell. Flatten your XML structure first if you need clean tabular output.
Column and value rules
| XML construct | CSV column | Notes |
|---|---|---|
| Child element text | Column value | Direct text content |
| Attribute | Column value | Flattened alongside children |
| Empty element <x/> | (empty cell) | Self-closing → empty string |
| Nested child element | (serialised JSON) | Flatten first for clean output |
| CDATA | Plain text | Markup stripped |
| Mixed content | Combined text | Text nodes joined |
| Namespace prefix | Prefix dropped | Local name used as column header |
Frequently Asked Questions
Your files stay on your computer. Dad promised.