XML to CSV Converter: Turn XML Records into CSV Rows
Paste or load XML, pick the repeating record element (one is suggested for you), and get RFC 4180 CSV. Attributes become @name columns, nested elements become paths such as author.name, and repeated children are joined or numbered. A built-in XML 1.0 parser runs entirely in this page: nothing is uploaded, no DTD or external file is ever loaded, and entity declarations are refused.
Read as UTF-8, up to 10 MB. Ctrl or Cmd + Enter converts. Live conversion pauses above 200,000 characters.
Paste XML or load the sample to begin.
XML error
- Records (rows)
- 0
- Columns out / found
- 0
- Elements parsed
- 0
- Deepest nesting
- 0
- Record path
- -
- CSV characters
- 0
Choose and order columns
Columns appear here after a successful conversion, in first-seen order across all records.
Table preview
The first rows of the CSV appear here as a table.
How it works and limits
- Parser. A small non-validating XML 1.0 parser written for this page checks well-formedness: one root element, matched and properly nested tags, quoted and unique attributes, legal names and characters, comments without
--, and declared namespace prefixes. Errors report a line and column (columns count characters, and tabs count as one). - Supported markup. The XML declaration, comments, processing instructions, CDATA sections (kept as literal text), the five predefined entities
& < > " ', and decimal or hex character references. Line breaks are normalized to LF before parsing, as XML requires. - Why entity declarations are refused. A DOCTYPE that declares
<!ENTITYcan make a few hundred bytes expand into gigabytes (the "billion laughs" attack) or point at local or remote files (XXE). This page never expands declared entities and never loads an external DTD, so documents that rely on them are stopped with an explanation instead of converting silently wrong. A DOCTYPE without entity declarations is accepted, but its attribute defaults are not applied. - Record detection. The suggestion is the most frequent element path that repeats among siblings and has attributes or child elements; plain repeated leaves such as
<tag>are only chosen when nothing structured repeats. Ties prefer the shallower path. Without any repetition, the root's only child type, or the root itself, is used. - Column names.
@attrfor record attributes,#textfor the record's own text (always when a record has text but no child elements, otherwise only when the option is on),childfor child text,parent.childfor nested elements,child.@attrfor their attributes, andchild.#textfor text mixed with child elements. A child counts as repeated when it occurs more than once under one parent in any record; numbered mode then always writeschild_1,child_2for that path so columns line up. In join mode, nested fields of repeated elements are joined position by position, with empty slots kept. - CSV. Fields are quoted only when they contain the delimiter, a double quote, or a line break; quotes are doubled. Values stay text exactly as in the XML (no number or date guessing). The optional formula guard prefixes
'to cells starting with= + - @, tab, or carriage return, which also changes negative numbers, so it is off by default. The output ends with a line break. - Limits. No XPath predicates, axes, or attribute paths; one record level per export; XML 1.1-only characters are rejected; files are read as UTF-8 whatever the declaration says; namespace declarations (
xmlns) are not exported as columns. Very large files are limited by device memory.