DataToolsLab
XML Tools

XML to CSV

Flatten repeating XML elements into CSV rows, with dotted column headers for nested children and attributes.

Loading tool…

What is XML → CSV?

An XML-to-CSV converter built around the record/repeat shape most XML data has: a root element containing many records of the same kind, each with the same fields. That shape flattens cleanly and that is what this does.

How it works

The repeated element is detected from the document structure (the deepest name that occurs several times), or supplied by you. Each occurrence becomes a row; leaf descendants and attributes become columns named by their dotted path, with attributes prefixed `@` to keep them distinct from child elements. Values are quoted when they contain a comma, quote or newline, and paths that appear more than once in a single record are reported rather than silently truncated to the last value.

  1. Paste the document. Drop in XML, a schema, a feed or an XPath expression. Everything is parsed in the page: no upload, no server round trip, and the tools keep working with the network switched off.
  2. Set the options that match your document. Indent unit, whether to keep comments, which dialect, which output method. The defaults are the safe ones — nothing that changes meaning is enabled for you.
  3. Read the result, then copy or download it. Results appear as you type, copy straight to the clipboard, and download with a sensible filename (.xml, .xsd, .csv). Reset returns every field to its default.

Examples

A minified document from an API response

Paste one line of XML and the Formatter indents it, wraps long start tags one attribute per line and normalises empty elements — without touching text inside mixed content.

An XPath that works in Chrome and not in your servlet

The XPath Tester evaluates against a real tree and reports the axis or function it cannot support, instead of returning zero nodes and letting you guess why.

A document that will not parse

The Validator gives line and column for every mismatched tag, stray ampersand and duplicate attribute, with the reason in words: which open element was expected, which was found.

A schema that only half matches your data

The XSD Validator marks each violation with the path of the offending node, and the Schema Generator goes the other way — inferring a starting-point XSD from real documents.

Common mistakes

Assuming a pretty-printer cannot change meaning

Whitespace between elements is often insignificant, but inside mixed content it is not: `<p>Hello <b>world</b></p>` must stay on one line. Formatting here re-indents element-only content and leaves mixed content alone.

Treating a validation pass as proof of interoperability

The DTD and XSD validators implement honest subsets. A document reported valid here can still be rejected by a full validator that understands identity constraints, substitution groups or XSD 1.1 assertions — each page lists what it does not cover.

Reading the whole document because the parser did

A DOCTYPE is not inert. If your parser resolves external entities, pasting an untrusted document is enough to read a file or call an internal URL. The XXE Risk Checker shows what a document asks for; the fix is in the parser configuration.

Forgetting that attributes and elements are not interchangeable

`<id>1</id>` and `id="1"` mean different things to every schema and every XPath. When converting to CSV or YAML the distinction is preserved (`@id`), because flattening it away is the change that costs an afternoon later.

Frequently asked questions

How do I know which element it will use for rows?

The tool detects it and shows the choice, with the count it found. If the detection is wrong, name the path yourself — the field takes the slash path of the repeating element, and the parent path is reported so you can see exactly what was matched.

Why is a repeated child reported as an error?

Because a CSV cell holds one value. If a record has three `<tag>` children, flattening them into one column keeps the last one and loses two silently; the tool refuses to guess and tells you the path instead. Either pick a deeper record or extract that field separately with the Attribute Extractor.

Are namespaces preserved?

The column header keeps the prefix as it appears in the document, so two same-named elements in different namespaces do not collide in one column. Check the header row before you import the result.

Online