Skip to content

XML to CSV

Delimiter
CSV —
Rows
—
Columns
—
Row element
—
Empty cells
—

Paste XML and the converter finds the repeated element under the root, turns each one into a CSV row and each child tag or attribute into a column. Two book elements with id, title and price give a header @id,title,price and two data rows, with commas and quotes escaped per RFC 4180.

About this tool

Feeds, exports from accounting systems and old SOAP responses often arrive as XML, while spreadsheets and import wizards want CSV. This converter reads the XML, walks past single wrapper elements, and treats the most repeated element as the record. Attributes become columns prefixed with @, leaf elements become columns by name, and nested elements are flattened into paths such as author/name. You can pick a comma, semicolon or tab delimiter, and a table lists every column with how many rows actually hold a value. The limit: deeply irregular documents, where records share little structure, give wide sparse tables, and namespaces are kept as plain prefixes rather than resolved. Parsing happens in your browser.

How to use it

  1. Add the XML

    Paste it into the box or open an .xml or .txt file from your device.

  2. Pick a delimiter

    Choose comma, semicolon (common for European Excel) or tab.

  3. Check the columns

    The table lists each column and how many rows filled it, so gaps are easy to spot.

  4. Copy the CSV

    Copy the result and paste it into a .csv file or a spreadsheet.

Examples

Two books with an id attribute

XML
<catalog><book id="1"><title>Dune</title><price>9.99</price></book><book id="2"><title>Say "Hi", Bob</title><price>5</price></book></catalog>
Delimiter
Comma

Result CSV: @id,title,price
1,Dune,9.99
2,"Say ""Hi"", Bob",5
Rows: 2
Columns: 3
Row element: book
Empty cells: 0

  1. Root path: catalog; repeated element <book> becomes one row each (2).
  2. Attributes become @name columns, nested elements become parent/child columns, repeats are joined with "; ".
  3. Cells holding the delimiter, a double quote or a line break are wrapped in quotes, and inner quotes are doubled (RFC 4180).

The id attribute becomes an @id column, and the title with a comma and quotes is wrapped and escaped.

A record missing a field

XML
<people><person><name>Ana</name><city>Porto</city></person><person><name>Ben</name></person></people>
Delimiter
Semicolon

Result CSV: name;city
Ana;Porto
Ben;
Rows: 2
Columns: 2
Row element: person
Empty cells: 1

  1. Root path: people; repeated element <person> becomes one row each (2).
  2. Attributes become @name columns, nested elements become parent/child columns, repeats are joined with "; ".
  3. Cells holding the delimiter, a double quote or a line break are wrapped in quotes, and inner quotes are doubled (RFC 4180).

Ben has no city element, so his city cell stays empty and a warning counts it.

Nested author element

XML
<feed><entry><id>7</id><author><name>Lee</name></author></entry><entry><id>8</id><author><name>Kim</name></author></entry></feed>
Delimiter
Comma

Result CSV: id,author/name
7,Lee
8,Kim
Rows: 2
Columns: 2
Row element: entry
Empty cells: 0

  1. Root path: feed; repeated element <entry> becomes one row each (2).
  2. Attributes become @name columns, nested elements become parent/child columns, repeats are joined with "; ".
  3. Cells holding the delimiter, a double quote or a line break are wrapped in quotes, and inner quotes are doubled (RFC 4180).

The name inside author is flattened into an author/name column.

How it is calculated

rows = most repeated child of the root; columns = attributes (@name) + leaf paths

row element
the child name that appears most often under the first element with several children
@name
an attribute of the row element, or of a nested element as path/@name
path
nested element names joined by a slash, such as author/name

The tool tokenises tags, checks that every closing tag matches its opener, and decodes the five standard entities plus numeric character references. CDATA text is kept as is and comments are dropped. If an element repeats inside one record, its values are joined with a semicolon and space. Column order follows first appearance. Cells are quoted only when they contain the delimiter, a double quote or a line break, following RFC 4180.

When not to use it

  • For mixed-content XML such as XHTML or DocBook, where text and tags interleave, a CSV loses the structure.
  • For files of many megabytes, a command-line tool like xmlstarlet or a script will be faster.
  • When the XML relies on a DTD to define custom entities, those entities are left undecoded.

Common mistakes

  • Opening a semicolon CSV in a spreadsheet set to commas, which puts every row in one column.
  • Pasting a fragment with two top-level elements; XML needs a single root.
  • Expecting numbers like 007 to survive a spreadsheet import, which drops leading zeros unless the column is text.

Frequently asked questions

How does it decide which element is a row?

It starts at the root and steps through any element that wraps a single child. At the first level with several children, the element name that repeats most often becomes the row, and each occurrence is one CSV line.

What happens to XML attributes?

Each attribute becomes its own column with an @ prefix, so id="42" on a book element turns into a column named @id. Attributes on nested elements get the path too, such as price/@currency.

How are nested elements handled?

Nested elements are flattened into slash paths. An author element holding a name element produces an author/name column. Deep nesting gives longer paths but still one row per record.

What if a record has the same child twice?

The values are joined into one cell with a semicolon and a space, for example two tag elements become red; blue. That keeps one row per record instead of splitting it.

Why are some cells wrapped in quotes?

RFC 4180 requires quotes around any value holding the delimiter, a double quote or a line break, and inner quotes are written twice. Spreadsheets read this back as the original text.

Is my XML uploaded anywhere?

No. Parsing and conversion run in your browser, and an opened file is read locally without being sent to a server.

Cite this tool

Using this tool in an assignment, article or report? Copy a citation, or a link for your website.

APA

Tools Directory Editorial Team. (2026, October 12). XML to CSV. Tools Directory. Retrieved October 27, 2026, from https://tools.milunir.com/developer-tools/data-format-converters/xml-to-csv/

MLA

Tools Directory Editorial Team. “XML to CSV.” Tools Directory, 12 Oct. 2026, https://tools.milunir.com/developer-tools/data-format-converters/xml-to-csv/. Accessed 27 Oct. 2026.

Chicago

Tools Directory Editorial Team. “XML to CSV.” Tools Directory. Last modified October 12, 2026. Accessed October 27, 2026. https://tools.milunir.com/developer-tools/data-format-converters/xml-to-csv/.

Link<a href="https://tools.milunir.com/developer-tools/data-format-converters/xml-to-csv/">XML to CSV – Tools Directory</a>