ConvertCSV

Converter tool

XML to CSV Converter

Convert XML records to CSV in seconds

Preview

Output Preview

No output yet. Upload or paste input and convert.

XML to CSV Converter

XML remains common in enterprise systems, government open-data feeds, supplier catalogs, and legacy SOAP APIs. Spreadsheets and many reporting tools still expect flat tables. This free XML to CSV converter parses an XML document in your browser, detects repeating record elements, and flattens their fields and attributes into spreadsheet columns you can open in Excel, Google Sheets, or a database import wizard.

Paste a full document or a fragment, or upload a .xml file. The tool walks the DOM to find sibling elements that share a tag name, treats each as one row, maps child element text and record-level attributes into columns, and produces RFC 4180–compatible CSV. Nothing from your XML payload is uploaded to a server as part of the conversion.

Below you will find how record detection works, how attributes and namespaces are handled, when nested XML needs preprocessing, Excel pitfalls after download, and a full troubleshooting and FAQ section for real-world XML exports.

Key features

  • Automatically detects the repeating record element in the XML tree — no XPath or schema configuration required.
  • Maps both XML attributes and child element text into separate CSV columns.
  • Strips namespace prefixes from element names by default so column headers stay readable (item instead of ns:item).
  • Leaves a cell blank rather than breaking the row when an optional element is missing from a given record.
  • Works from pasted XML text or an uploaded .xml file — no local XML tooling needed.
  • Runs entirely in the browser using the built-in DOM parser so file contents are not sent to a server for conversion.
  • Produces standard CSV with a header row derived from detected elements and @attributes.

About the XML to CSV format

CSV is a plain-text table: one header row, then one row per record, with fields separated by commas. XML is hierarchical: elements nest, attributes attach to tags, and the same local name can appear under different parents. Conversion means choosing which repeating element is “one row” and projecting its direct fields into columns.

This converter looks for the first set of sibling elements that share a tag name and repeat under a common parent. That repeating element becomes the record. Direct child elements become columns named after the tag (namespace prefixes stripped for readability). Attributes on the record element itself become extra columns prefixed with @ so you can tell them apart from child text columns.

Deep grandchild structures are not fully exploded into extra rows. If each record contains nested collections (line items inside an order), you usually need to trim or restructure the XML first, or convert nested sections separately. Keep the original XML when hierarchy and schema validation still matter for downstream systems.

How it works

The parser loads your text into a DOM tree in the browser. It then looks for the first level of elements that repeats more than once under a common parent — that repeating element is treated as one record per row.

For each record, direct child elements become columns (named after the tag, with namespace prefixes removed), and attributes on the record element itself are added as additional columns prefixed with @. Text content is trimmed of surrounding whitespace before being placed in a cell.

Any record missing an optional child element simply gets a blank cell for that column instead of shifting the remaining columns. The result is escaped for CSV (commas, quotes, and newlines handled per common spreadsheet expectations) and ready to copy or download.

Common use cases

  • Converting an RSS or Atom feed export into rows for content auditing or editorial planning.
  • Extracting product catalog records from a supplier XML data feed for price comparison in Excel.
  • Turning a government or open-data XML dump into a spreadsheet for analysis and charts.
  • Flattening SOAP API response XML for debugging, QA review, or ticket attachments.
  • Sharing enterprise EDI-style XML extracts with teammates who only work in spreadsheets.
  • Preparing sample rows from an XML schema example for documentation or training materials.

How to use this tool

  1. Paste the XML document or upload a .xml file — a full document or just the relevant fragment both work.
  2. Let the converter identify the repeating record element and list the columns it detected.
  3. Check the preview to confirm the detected record element matches what you expect (for example product, not the wrapping products container).
  4. Spot-check attribute columns (@id) and optional fields that appear only on some records.
  5. Download the CSV or copy it once the column mapping looks correct, then open it in your spreadsheet or importer.

Example

Input XML

<products>
  <product id="101">
    <name>Widget</name>
    <price>9.99</price>
  </product>
  <product id="102">
    <name>Gadget</name>
    <price>14.50</price>
  </product>
</products>

Output CSV

@id,name,price
101,Widget,9.99
102,Gadget,14.50

Tips for best results

  • Prefer XML with a clear repeating element (product, item, record, entry) — detection is most reliable then.
  • Trim the paste to the repeating section if the full document has multiple unrelated repeating groups.
  • Confirm the detected record tag in the preview before downloading (product vs products container).
  • Keep attribute usage consistent across records so optional attributes do not produce sparse, confusing columns.
  • Validate hand-edited or log-extracted XML first — unescaped & and unclosed tags are common parse failures.
  • After download, open a sample in Excel or Sheets and check @attribute columns and a few optional fields.
  • For very large files, split by record count before converting to avoid browser memory pressure.

Common errors and how to fix them

The XML has no clear repeating element, so the CSV ends up with only one row.
The parser needs a parent with multiple same-named children to detect a record pattern. If your document has a flat, non-repeating structure, wrap the values in a repeating tag first, or convert a fragment that already contains repeated siblings.
Some columns are always empty even though the data should be there.
That element is likely present in only some records — check a record that does have it and confirm the tag name matches exactly, since XML tag names are case-sensitive (Price and price are different elements).
Column names show unexpected prefixes or collide with each other.
Namespace prefixes are stripped for the common single-namespace case, but a document mixing multiple namespaces that reuse the same local element name can still collide. Rename the conflicting elements in the source, or process each namespace separately.
The tool reports a parse error on a document that looks fine visually.
Unescaped & characters (should be &amp;) and unclosed tags are the most common causes. Validate the XML with a linter first if it was hand-written or extracted from a log file.
Nested line items or child lists do not appear as extra CSV rows.
Only the detected record element becomes rows. Nested collections inside each record are not exploded automatically. Extract the nested list into its own XML fragment and convert that separately, or flatten in a script before pasting.
Excel shows long IDs in scientific notation or drops leading zeros.
This is Excel auto-formatting on open. Format those columns as Text after import, or keep critical identifiers as text when you continue the workflow in a spreadsheet.

Best practices

  • Trim the XML down to the repeating record section before pasting if the full document has multiple unrelated repeating elements.
  • Keep attribute usage consistent across records — either always or never use a given attribute — to avoid sparse columns.
  • Prefer well-formed XML; full documents with declarations parse fine, but fragments are often easier to review in the preview.
  • For very large XML exports, split the file by record count before conversion to avoid browser memory limits.
  • Document which tag was treated as the record and which fields map to which columns when you hand the CSV to someone else.
  • Preserve the original XML whenever schema validation, namespaces, or nested structure may be needed again.
  • Spot-check row count against the number of repeating elements in the source before sharing the file widely.

What XML to CSV conversion actually does

XML and CSV solve different problems. XML expresses hierarchy, attributes, namespaces, and mixed content for systems that need a schema-friendly tree. CSV is a lowest-common-denominator table that almost every spreadsheet and many importers understand. Converting XML to CSV means choosing a flat projection: one repeating element type becomes rows, and its direct fields become columns.

That projection is deliberate. You keep the leaf values that matter for analysis or sharing, and you encode attributes with an @ prefix so they stay distinguishable from child element text. Anything deeper than one level of children — especially nested repeating lists — needs a design choice: extract separately, summarize, or leave out of the spreadsheet view.

This page is aimed at everyday conversion: take a catalog, feed, or API response, produce a downloadable CSV, and move on. It is not a full XSLT pipeline. For nightly warehouse loads with strict schemas you would use dedicated ETL. For a one-off supplier file, support ticket, or open-data sample, a browser converter is usually the fastest path.

When to convert XML to CSV (and when to keep XML)

Convert to CSV when the consumer is a human in a spreadsheet, a tool that only accepts tabular uploads, or a workflow that needs simple filters, sorts, and pivots. Analysts and operations teams often cannot navigate nested XML comfortably even when engineers can. CSV also makes side-by-side comparison of two exports easier because rows and columns line up visually.

Keep XML when you still need nesting for application logic, when nested arrays of records are first-class (order line items, repeating addresses), or when XSD validation and namespaces matter for a production importer. Round-tripping through CSV loses type information and hierarchy that a schema expects.

A practical middle path is to convert a filtered fragment for sharing while archiving the full XML. Many teams paste only the repeating product or entry list into this tool and keep the complete document for engineering use.

  • Good fit: supplier catalog → Excel review, RSS/Atom → content audit sheet, SOAP sample → QA spreadsheet.
  • Poor fit: deeply nested documents with repeating child collections that must stay relational.
  • Better as a script: recurring conversions with fixed XPath, schema checks, and automated delivery.

How repeating records are detected

The happiest path is a container with many same-named children: products/product, items/item, entries/entry. The converter treats each of those children as one CSV row. Headers come from the union of direct child tags and record-level attributes seen across those records.

If several groups of repeating siblings exist in the document, detection focuses on the first clear pattern it finds. That is why trimming to the relevant section helps when a feed wrapper, metadata block, and payload list all contain repeats.

A single non-repeating root with unique children does not form a useful multi-row table. In that case wrap records consistently or convert a list fragment you already know is tabular. Optional fields that appear on only some records become blank cells rather than shifted columns — useful for sparse catalogs, but worth reviewing so “missing” does not look like data loss.

Attributes, child elements, and column naming

Child element text becomes a column named after the element’s local name. Attributes on the record element become columns prefixed with @ (for example @id). That convention keeps id-as-attribute distinct from an id child element if both exist.

Namespace prefixes are stripped so headers stay readable. In a single-namespace document that is almost always what you want. If two namespaces both use a local name like name, stripped headers can collide — rename or process namespaces separately before converting.

XML is case-sensitive. Price and price are different tags. Inconsistent casing across records produces separate columns or empty cells that look like bugs. Normalize tag casing in the exporter when you control it.

Nested XML, mixed content, and what will not flatten

Only direct children of the detected record become columns. Grandchildren are not walked into dotted paths by default. If each order contains many line elements, those lines will not appear as extra CSV rows automatically.

Mixed content — text nodes interleaved with child elements — is awkward in spreadsheets. Prefer element-centric XML for conversion, or extract the text you need into dedicated child tags first.

CDATA sections are generally treated as text content of their parent. Comments and processing instructions are not useful spreadsheet columns and are ignored for the tabular projection. DOCTYPE declarations may parse, but large external DTD scenarios are outside what a casual browser conversion is for.

Encoding, entities, and well-formedness

Browsers parse XML strictly compared with HTML. A bare & in text must be written as &amp;. Unclosed tags and mismatched nesting fail the parse before any CSV is produced. If your “XML” was scraped from a log or email, run a validator first.

Character encoding matters when the file was saved from older Windows tools. Prefer UTF-8. If accented characters look wrong after download, re-check the source encoding rather than blaming column mapping.

Entity references that the browser can resolve in a standalone document are fine; exotic external entities are not something you should rely on for a client-side paste workflow. Prefer self-contained, well-formed documents.

Excel, Google Sheets, and opening the CSV

The CSV follows common expectations: comma separators and quoting when fields contain commas or newlines. Locales where Excel expects semicolons may need Text Import with an explicit comma delimiter. Google Sheets usually handles UTF-8 CSV uploads more smoothly.

Long numeric IDs and codes with leading zeros are classic Excel traps after open. Format those columns as Text. Dates in XML text may also be reinterpreted depending on locale — prefer unambiguous ISO-style strings in the source when you control the exporter.

Attribute columns (@id) are ordinary text headers. They are not Excel metadata; rename them after download if your template forbids the @ character.

Typical workflows that use this converter

Supplier and partner feeds: receive a product or pricing XML file, convert the repeating items to CSV, and compare in a spreadsheet before importing into a PIM or ERP staging sheet.

Feeds and content: turn RSS/Atom-like structures into rows for editorial audits, broken-link checks, or migration planning.

Integration debugging: paste a SOAP response body, confirm which fields the API actually returned, and attach a CSV sample to a ticket for non-technical stakeholders.

Open data and reporting: flatten a government XML dump for charts and filters when the portal’s native tools are limited.

Browser limits, privacy, and large files

Conversion runs in your browser with the DOM parser and JavaScript. Your XML content is not sent to a Convert CSV server as part of the transform. The page itself still loads over the network, and the site may use analytics or advertising as described in the privacy policy.

Very large documents can exhaust memory or freeze a tab. Split by record batches, convert chunks, then concatenate CSVs if needed — or use streaming/command-line tools for multi‑hundred‑megabyte files.

For sensitive enterprise data, local conversion is preferable to uploading to an unknown third-party API. Clear downloads and paste buffers on shared machines when finished.

XML to CSV versus XSLT or a script

XSLT or a small script gives you full control: explicit XPath for the record node, nested tables, renaming, filtering, and scheduled jobs. Use that when the mapping is part of a product or data platform.

A browser converter wins on time-to-first-result. No toolchain setup, no stylesheet authoring for a one-off feed. Once the same mapping repeats weekly, automate.

Teams often use both: this tool for exploratory conversion and a checked-in transform once the column contract stabilizes.

Quality checklist before you share the CSV

Match the number of data rows to the number of repeating elements you intended. Wrong record detection often shows up as one row or far too few rows.

Scan headers for @attributes and unexpected local names after namespace stripping. Spot-check optional fields and a record that includes every column.

Open the file in the same app your recipient uses. Note delimiter and UTF-8 import steps for Excel in other locales. Keep the source XML if nested data may be needed again.

  • Row count matches the repeating record count you expect.
  • Record element tag is the one you intended (not the container).
  • Attribute and child columns look correct for a sample record.
  • No parse errors; entities and tags are well-formed in the source.
  • Original XML retained when hierarchy may still matter.

Related tools and next steps

To go the other direction — spreadsheet rows back into XML — use the CSV to XML converter and set root and record element names to match your target schema.

If your source is JSON rather than XML, use JSON to CSV. For cleaning columns after download, open the Online CSV Editor or Edit CSV tools.

Format guides on the site cover CSV delimiters, encoding, and Excel quirks when the conversion succeeded but the spreadsheet open step still looks wrong.

Frequently asked questions

How does the converter know which element represents one row?

It looks for the first set of sibling elements sharing the same tag name that repeats more than once under a common parent, and treats each of those as one record/row.

Are XML attributes included in the CSV?

Yes — attributes on the record element are added as extra columns, prefixed with @ to distinguish them from child-element columns.

Can it handle deeply nested XML with sub-records inside each record?

Only the direct children of the detected record element become columns. Grandchild elements are not automatically flattened — restructure the XML or process nested sections separately if you need that data.

What happens to XML namespaces?

Namespace prefixes are stripped from element names by default so headers stay readable. If your document uses multiple namespaces with colliding local names, you may need to rename elements first.

Does this tool send my XML file to a server?

No. Parsing happens entirely in your browser using the DOM XML parser built into JavaScript. See the Privacy Policy for how the website itself uses analytics and advertising.

How do I go the other direction, from CSV back to XML?

Use the CSV to XML converter, which lets you set a custom root and record element name and generates well-formed XML from your spreadsheet rows.

Why do I only get one CSV row?

The document may lack repeating same-named siblings under a parent. Wrap records in a repeating tag, or paste only the list fragment that already repeats.

Why are some cells empty on certain rows?

Optional elements or attributes missing from that record become blank cells. Confirm tag spelling and case — XML names are case-sensitive.

What is the maximum file size?

There is no fixed server quota because processing is local, but very large XML files can exhaust browser memory. Split into batches or use a command-line converter for bulk jobs.

Does the tool support XSD validation?

No. It flattens well-formed XML into CSV; it does not validate against an XSD. Validate in your integration toolchain if schema compliance is required.

Can I choose a different record element manually?

Detection is automatic based on repeating siblings. To force a specific list, trim the XML so that list is the clear repeating pattern before pasting.

Is the output compatible with Google Sheets?

Yes. Download the CSV and import or upload it into Google Sheets. Still verify attribute columns and numeric IDs after import.

For more background on data formats and conversion workflows, read our format guides or browse the converter blog for step-by-step walkthroughs linked to each tool.