Converting XML to CSV format means turning a repeating XML record element into one CSV row per occurrence, with attributes prefixed by @, direct child text becoming scalar columns, and repeated child names stored as compact JSON arrays inside a single CSV cell. The output follows the RFC 4180 profile with CRLF line endings, doubled embedded quotes, and UTF-8 encoding without a byte-order mark. The browser parses your input as application/xml with DOMParser, rejects any document containing a DOCTYPE declaration, and stops on malformed tags, quotes, or entities before producing a row. Because XML has no universal record-to-table mapping, this conversion is intended for predictable feeds such as a catalog containing repeated item elements with scalar child text. Nested markup is flattened to descendant text, so element boundaries, child attributes, and mixed-content ordering are not preserved in the CSV. The XML to CSV Converter runs entirely in your browser and never uploads the document.

What XML to CSV Format Conversion Actually Means
XML is hierarchical and CSV is rectangular. Converting between them is a flattening step that picks one element type as the row anchor, turns each match into one record, and reduces the rest of the XML inside that record to scalar column values. The conversion is intentionally lossy: any element boundary, child attribute, comment, processing instruction, or prefix declared only for structure disappears. Namespaces are matched literally as qualified names, so a record named ns:item in the source still appears as ns:item in the resulting column header; the converter does not expand the prefix, normalize it, or look up a schema.
The practical result is a rectangular grid you can paste into Excel, load with any CSV parser, or feed into a database importer. The columns are stable, the order is deterministic, and every cell is plain text. That makes the output predictable for downstream code, even when the source XML was not.
Inputs the Converter Expects Before You Click Convert
The converter needs two things: a well-formed XML document and the exact qualified name of the repeating element that should become one row. Paste the XML first. If your file is minified and hard to scan, run it through an XML formatter in your browser so you can see the indentation and verify the structure before submitting it.
The record name is case-sensitive and must be a fully qualified element name. For a catalog that looks like <item>...</item>, the name is item. For a namespaced feed that looks like <ns:item>...</ns:item>, the name is ns:item, typed exactly. The converter matches it with getElementsByTagName, so a name like ITem will not match item, and a typo will produce a no-match error rather than silently picking the wrong element. Any document that contains a DOCTYPE declaration is rejected before parsing, which means external entities, DTD defaults, and custom entity definitions are not processed.
Malformed tags, unescaped quotes, or bad entities surface as a parser error and block the conversion. Fix the XML first, then re-paste.
Convert an XML Document to CSV Format Step by Step
- Open the XML to CSV Converter and paste your well-formed XML into the input area.
- Type the exact qualified name of the repeating element into the record-name field — for example item or ns:item.
- Leave formula protection enabled if a human will open the resulting CSV in Excel, Numbers, or Google Sheets, since values beginning with =, +, -, or @ are tab-prefixed inside quotes to reduce accidental formula execution.
- Click convert and watch for the record count and column count reported in the result panel.
- Compare those counts against your source: count how many times the record element occurs in the XML and how many distinct attribute and direct-child names appear across one occurrence.
- Copy the CSV to the clipboard or download it as a UTF-8 text/csv file without a byte-order mark.
- Open the CSV in a text editor first, scan a few cells, then import it into your spreadsheet or pipeline.
If the column count is lower than expected, check whether some direct children only appear in later records and need to be inspected under the deterministic union rule described below. If the record count is lower, the qualified name does not match a single occurrence in the source.
How Attributes, Text, and Repeated Children Map to Columns
Each matching record element becomes one row. The columns come from a deterministic union: attributes of the record, each distinct direct child element name, and a #text column when the record contains direct text outside child elements that is not only whitespace. The first record encountered determines the initial column order, and previously unseen fields from later records are appended in the order they are discovered.
| Source in XML | CSV Column | Cell Contents |
|---|---|---|
| Record attribute | @name (for example @id) | trimmed attribute value |
| Single direct child element | qualified name (for example price) | trimmed descendant text |
| Same direct child repeated | qualified name (one column) | compact JSON array of trimmed texts |
| Direct text outside child elements | #text | text content (only when not only whitespace) |
| Nested elements | merged into the parent child column | descendant text concatenated and trimmed |
The @ prefix distinguishes record attributes from child elements that happen to share a name. The repeated-child behavior matters because XML lets a record carry several <tag> children with different meanings, and silently keeping only the first or last value would be a quiet data loss; packing them into a JSON array inside one CSV cell is the explicit choice this converter makes, and is covered in more detail in the guide on converting XML to CSV without losing repeated fields. Missing columns in any particular record become empty fields, so the rectangular grid stays intact even when records are sparse.
Verifying the CSV Output Before Replacing a Source File
A CSV conversion is only useful if the output matches the source on the rows and columns you care about. Open the CSV in a text editor first so quotes, commas, and line endings are visible. Spot-check three things: a row whose record contains repeated children (its cell should be a JSON array, not a single value), a row whose record is sparse (its missing fields should be empty strings, not omitted), and any cell whose value starts with =, +, -, or @ (it should be tab-prefixed inside a quoted field while protection is enabled).
Then load the file into a spreadsheet with controlled column types. Dates, numbers, leading zeros, identifiers, and Booleans come through as the text spellings from the XML, and a spreadsheet may still guess types when opening the file. If leading zeros or numeric precision must survive, run an import wizard or pre-format the destination columns as text before pasting.
When XML to CSV Format Conversion Is the Wrong Choice
The converter has hard limits: 500,000 XML characters of input, 10,000 matching records, 200 columns, and 5,000,000 CSV characters of output. When any of those is exceeded the converter fails rather than truncates, which protects the result from silent data loss but means you should pre-check record counts on large feeds.
It also cannot do things XML allows but CSV cannot express. It does not infer records automatically from arbitrary XML, expand nested arrays into multiple rows, join parent values onto children, evaluate XPath, normalize namespaces, preserve schema types, or validate against an XSD. Mixed-content documents lose their markup. Nested elements lose their structure. For those contracts, use an explicit transformation such as XSLT or application code that has access to the full tree.
Two safety notes worth keeping in mind. The formula-protection option follows the Excel-oriented mitigation described by OWASP for CSV injection, and the CSV output is formatted to the profile described in RFC 4180. Disabling protection is a deliberate choice that exposes spreadsheet recipients to formula evaluation; leave it on unless you control the destination and need exact raw values.
For a deeper look, see Convert XML to JSON in Python and in the Browser.