XML to CSV Converter
CV-112Paste XML and get CSV. The repeated elements, such as each book in a catalog, become rows, and their attributes and children become columns.
Runs in your browser. Nothing is uploaded.
XML (optional first line: -- record: elementName)
CSV
How to use it
- Paste your XML.
- Optionally add a first line -- record: book to name the record element.
- Pick the delimiter and whether to include attributes.
- Press XML to CSV, then copy or download.
How records are found
XML is a tree and CSV is flat, so the tool must decide what a row is. By default it takes the first set of same-named sibling elements it finds, looking from the root downward. If there is none, the root element is the single record. To choose yourself, put -- record: book on the first line and every book element becomes a row. A wrong guess is easy to fix this way when your file has several repeating elements.
How columns are named
Attributes become @id style columns, child elements use their own name, and deeper elements are joined with dots, such as price.@currency. When a record also has text next to children or attributes, it goes under #text. An element that repeats inside a record is numbered, tag[1] and tag[2]. Records that lack a column get an empty cell. Namespace prefixes stay in the names, comments are ignored and a DOCTYPE is skipped, not expanded. Nothing is validated against a schema.
Error messages and what to do
| Message | What it means | Fix |
|---|---|---|
No root element found. XML needs one element such as <root>...</root> | The input has no XML element. | Paste well-formed XML with one root element. |
Questions people ask
How do I convert XML to CSV?
Paste the XML and press XML to CSV. The tool finds the repeated element, writes one row for each and builds columns from attributes and child elements. Download the .csv or copy it.
It picked the wrong element as the row. What now?
Put -- record: elementname on the first line of the input, using the exact element name. Every element with that name becomes a row, wherever it sits in the document.
What happens to nested elements?
Nested elements are flattened into columns with dotted names, such as address.city. Repeated nested elements are numbered, so a record with two phone elements gets the columns phone[1] and phone[2].
Can I leave out attributes?
Yes. Untick Include attributes and only element text becomes columns, which gives a narrower table. With it ticked, which is the default, attributes appear as columns that start with the @ sign.
Does it check the XML?
It reads the XML strictly enough to report a mismatched or unclosed tag with its line and column, but it does not validate against a schema or a DTD, and a DOCTYPE is skipped, not expanded.
About this tool
XML is a tree and CSV is flat, so the tool must pick the records. By default it takes the first set of same-named sibling elements it finds, looking from the root downward (the book elements in the sample); with none, the root element is the single record. To choose yourself, put -- record: book on the first line. Each record becomes one row. Columns are its attributes (@id), its child elements (title), deeper elements joined with dots (price.@currency), and the record text under #text when it also has children or attributes. A name that repeats inside a record is numbered, tag[1] and tag[2]. Missing values are empty cells. Namespace prefixes stay in the names, comments are ignored, and a DOCTYPE is skipped, not expanded. It does not validate against a schema.