XML to CSV Converter
Convert repeated XML record elements to RFC-style CSV with attributes, repeated children, exact tag selection, and optional formula protection.
Privacy: your files never leave your device. All processing happens locally in your browser.
How to use
- 1.Paste well-formed XML and enter the exact qualified name shared by the repeating record elements.
- 2.Keep formula protection on for human-opened spreadsheets, then convert and verify the record and column counts.
- 3.Copy or download the CSV, inspect repeated-child JSON cells and type-sensitive values, and compare against the source.
About XML to CSV Converter
XML to CSV Converter turns repeated XML record elements into a rectangular comma-separated table. Paste an XML document, enter the exact qualified name of the repeating record element, choose whether to protect spreadsheet formula-like values, convert, and copy or download the CSV. Parsing and conversion happen in the browser; the document is not uploaded.
The browser parses the input as application/xml with DOMParser. Malformed tags, quotes, or entities return an error document and block conversion. DOCTYPE declarations are rejected before parsing, so this utility does not process external entities, DTD defaults, or custom entity definitions. The record name must be an exact XML qualified name such as item or ns:item and is matched case-sensitively with getElementsByTagName.
Each matching element becomes one row. Attributes on the record become columns prefixed with @, such as @id. Direct child elements become columns using their exact qualified names. Direct text outside child elements becomes a #text column when it is not only whitespace. Column order is deterministic: fields from the first record appear first, and previously unseen fields from later records are appended.
A direct child element contributes its trimmed text content. Nested markup is flattened to descendant text, so element boundaries, child attributes, comments, processing instructions, prefixes declared only for structure, and mixed-content ordering are not preserved. When the same direct child name occurs more than once in one record, its text values are stored as a compact JSON array inside one CSV cell instead of silently keeping only the first or last value.
CSV output follows the commonly documented RFC 4180 profile: columns are comma-separated, records use CRLF, fields containing commas, quotes, tabs, carriage returns, or line feeds are enclosed in double quotes, and embedded quotes are doubled. Spaces are preserved. Missing columns become empty fields. The first record is a header row built from the deterministic column union.
Spreadsheet programs may interpret cells beginning with =, +, -, or @ as formulas. The protection option is enabled by default and prefixes those values with a tab inside a quoted field, following the Excel-oriented mitigation discussed by OWASP. This intentionally changes the cell data and is not universally safe for every spreadsheet or programmatic importer. Disable it only when exact raw values are required and the destination treats all cells as inert text.
XML has no universal record-to-table mapping. This tool is intended for predictable feeds such as a catalog containing repeated item elements with scalar child text. It does not infer records automatically, expand nested arrays into multiple rows, join parent values, evaluate XPath, normalize namespaces, preserve schema types, validate against XSD, or convert arbitrary mixed-content documents without loss. Use an explicit transformation such as XSLT or application code for those contracts.
The downloaded file uses UTF-8 text/csv without adding a byte-order mark. Some legacy spreadsheet configurations may require an import wizard or explicit UTF-8 selection. Dates, numbers, leading zeros, identifiers, and Booleans remain text spellings from XML; a spreadsheet may still guess types when opening the file. Import with controlled column types when leading zeros or precision must survive.
Limits are 500,000 XML characters, 10,000 matching records, 200 columns, and 5,000,000 CSV characters. The converter fails rather than truncating. Eight external fixtures cover plain fields, commas, quotes, line endings, spaces, Unicode, and two formula-leading cases. Additional tests cover attributes, repeated children, missing columns, invalid names, DOCTYPE rejection, and no-match errors. Compare row and column counts with the source before replacing a production export.
Methodology & sources
Parses XML with the browser DOM, rejects DOCTYPE and parser-error documents, selects exact qualified record names, flattens record attributes and direct-child text into deterministic union columns, preserves repeats as compact JSON arrays, and serializes RFC-style CRLF CSV with optional formula-cell protection.
Frequently asked questions
- Why do attribute columns start with @?
- The prefix distinguishes record attributes from child elements that may use the same name.
- What happens to nested XML elements?
- Their descendant text is flattened into the direct-child column. Structure and child attributes are not preserved, so the conversion is intentionally lossy.
- Why are some spreadsheet cells prefixed with a tab?
- With protection enabled, values beginning with formula characters are tab-prefixed inside quotes to reduce accidental spreadsheet formula execution. Disable it for exact raw exports after assessing the destination.
Related tools
- XML to JSON ConverterConvert bounded, well-formed XML into readable JSON locally with attributes, text, namespaces, and repeated elements preserved.
- CSV to HTML Table ConverterConvert RFC 4180-style CSV into escaped, structured table markup with a safe React preview and exact clipboard output.
- CSV To JSONParse a bounded RFC 4180-style comma file locally and export string-preserving JSON without losing quoted commas, quotes, or line endings.
- XPath TesterEvaluate XPath 1.0 against detached XML and inspect node, string, number, or Boolean results without inserting matched markup.
- ANSI Color Codes GeneratorBuild and copy raw SGR escape sequences and search the standard 8 plus bright 8 terminal color codes.
- ASCII TableLook up every standard 7-bit ASCII code with exact decimal, hexadecimal, octal, and binary values.