XML to CSV
Flatten repeated XML elements into a CSV table — columns inferred from child tags and attributes. Runs entirely in your browser, no upload.
About this tool
XML to CSV turns a block of XML with repeated elements into a flat CSV table you can open in a spreadsheet, load into a database, or hand to another tool. It runs entirely in your browser — your data is never uploaded.
Each repeated record element becomes one row. The tool reads the record's
child elements and uses their tags as the CSV column headers, in the order they
first appear. Nested elements are flattened into dot-notation columns — an
<address><city> becomes the column address.city — so deeply structured XML
maps cleanly onto a table without losing data. Missing fields become empty cells,
repeated tags are kept as tag, tag.2, tag.3, and XML entities (&,
<) and CDATA blocks are decoded back to plain text. Values that contain the
delimiter, quotes, or newlines are CSV-quoted automatically.
How to use it
- Paste your XML.
- Leave Record tag blank to auto-detect the repeated element (the most
common direct child of the root), or type a tag such as
bookoritem. - Toggle Include attributes as columns to add attribute values —
@idon the record element,price@currencyon a child element. - Pick a delimiter if you need tab, semicolon, or pipe instead of a comma.
Example
Input:
<users>
<user id="1"><name>Ada</name><role>admin</role></user>
<user id="2"><name>Bo</name><role>editor</role></user>
</users>
With attributes on, record tag user, you get:
@id,name,role
1,Ada,admin
2,Bo,editor
Notes
- Namespaced tags (
ns:title) are flattened to their local name (title). - Auto-detect picks the most frequent direct child of the root element; set the record tag explicitly if your XML nests records deeper.
- Everything is computed locally and deterministically — no account, no AI model, no server round-trip.
FAQ
How does auto-detect pick the record element?
When you leave Record tag blank, the tool counts the direct children of
the root element and picks the tag that appears most often (ties break to the
first one seen). That's right for a flat <catalog><book>… list, but if your
records are nested deeper, type the tag (e.g. book or item) explicitly.
What happens to nested elements and repeated tags?
Nested elements are flattened into dot-notation columns, so
<address><city> becomes address.city. If a child tag repeats within one
record, the copies become tag, tag.2, tag.3, … Columns are created in
first-seen order, and any record missing a field just gets an empty cell.
Can I include XML attributes as columns?
Yes — Include attributes as columns is on by default. An attribute on the
record element becomes @id, and one on a child element becomes
price@currency. Turn it off to keep only element text. Namespaced tags like
ns:title are flattened to their local name (title).
Are special characters and entities handled safely?
Yes. XML entities (&, <) and CDATA blocks are decoded back to
plain text, and any value containing the delimiter, a quote or a newline is
CSV-quoted automatically — so the output opens cleanly in a spreadsheet. Pick
a tab, semicolon or pipe delimiter if a comma clashes with your data.
Developer & Automation Access
Run it from the terminal
Same engine as this page, headless — via the gizza CLI:
gizza tool xml-to-csv "<catalog>
<book><title>Dune</title><author>Herbert</author></book>
<book><title>Hyperion</title><author>Simmons</author></book>
</catalog>"New to the CLI? Get gizza →
Open it by URL
Pre-fill and auto-run this tool with query parameters — the names match the API/CLI:
https://gizza.ai/tools/xml-to-csv/?xml=%3Ccatalog%3E%0A%20%20%3Cbook%3E%3Ctitle%3EDune%3C%2Ftitle%3E%3Cauthor%3EHerbert%3C%2Fauthor%3E%3C%2Fbook%3E%0A%20%20%3Cbook%3E%3Ctitle%3EHyperion%3C%2Ftitle%3E%3Cauthor%3ESimmons%3C%2Fauthor%3E%3C%2Fbook%3E%0A%3C%2Fcatalog%3E&record=book&attributes=true&delimiter=%2CMachine-readable descriptor: tool.json — title + parameters JSON Schema for agents.
