CSV to XML — Convert CSV Data to XML Format
Convert CSV data to XML with configurable root and row element names. Optional attribute mapping, runs entirely in your browser. No uploads, no limits.
CSV to XML is one of the older data conversion chores, dating back to the days when XML was the default interchange format for everything from SOAP APIs to RSS feeds to Office documents. The conversion is mechanical — each row of the CSV becomes a <row> element, each column header becomes a child element (or attribute) name, and each cell value becomes the text content — but the output format is configurable in ways that matter for downstream consumers. Some XML schemas expect attributes (<row name=\"Alice\" age=\"30\"/>); others expect child elements (<row><name>Alice</name><age>30</age></row>); some require a specific root element name; some need a namespace. The tool exposes those choices directly so the output matches the destination schema on the first try.
The non-obvious thing about the conversion is XML escaping. CSV cells can contain any character, including <, >, &, and quote characters, all of which have special meaning in XML. A naive string concatenation that wraps each cell in <name>VALUE</name> produces broken XML if the value contains < — the parser will see an unclosed tag and fail. The tool escapes the five XML-significant characters (<, >, &, ', \") automatically, producing output that any XML parser can read back to the exact original CSV values. CDATA sections are not used because they are a workaround for escaping failure, not a substitute for proper escaping.
For a final hand-off: if the destination is a SOAP or REST API that expects XML, confirm the schema’s element-vs-attribute convention before generating — the wrong choice produces output that parses but does not validate. If the destination is a relational database, CSV-to-XML is the wrong direction; most databases accept CSV directly via bulk import. If the destination is a feed (RSS, Atom, sitemap), the XML flavor is fixed and you may want to use a feed-specific generator rather than a generic CSV-to-XML tool. The tool here is the right pick for ad-hoc XML output where the schema is simple and the consumer is a generic XML parser.
How to use
Paste your CSV data
Drop the CSV into the input area, or load a .csv file. The tool auto-detects the delimiter (comma, semicolon, tab) and the presence of a UTF-8 BOM. The first row is treated as the header by default.
Configure the XML structure
Pick a root element name (the container, default `<rows>`) and a row element name (each record, default `<row>`). Optionally map the header columns to XML attributes instead of child elements.
Copy or download the XML
Copy the XML to your clipboard, or download it as a .xml file. The output is a single self-contained XML document with the standard `<?xml version="1.0"?>` declaration and UTF-8 encoding.
Frequently asked
Can I use any delimiter?
Yes — the auto-detect inspects the first few kilobytes and chooses between comma, semicolon, tab, and pipe. You can also force a delimiter in the settings if auto-detect picks the wrong one for a non-standard input.
What is the difference between attributes and child elements?
An attribute-based row looks like `<row name="Alice" age="30"/>`. A child-element row looks like `<row><name>Alice</name><age>30</age></row>`. Attributes are more compact; child elements are easier to extend with nested data later.
How are special XML characters escaped?
The tool escapes `<`, `>`, `&`, `'`, and `"` automatically. A CSV cell with `A & B` becomes `A & B` in the XML, which any XML parser reads back as the original `A & B`. CDATA sections are not used; entity escaping is the standard approach.
Can I add a schema reference?
Yes — the 'XSD reference' field lets you add an `xsi:noNamespaceSchemaLocation` attribute to the root element, pointing to a .xsd file. The reference is added but not validated — pair the conversion with a separate XML validator if schema conformance matters.
Does the first row become the schema?
Yes — the first row of the CSV is treated as the field names. Each field name becomes an XML element (or attribute) within each row. If the CSV has no header, toggle the 'no header' option and the field names become generic `field1`, `field2`, etc.
Limitations
- No nested structureCSV is a flat grid. The XML output is also flat — each row has the same fields, and there is no way to represent nested objects or arrays. For hierarchical data, start from JSON or YAML instead.
- No namespaces by defaultThe output uses no XML namespace. If the destination schema requires a namespace (most SOAP, RSS, and Atom feeds do), add it manually after the conversion. The tool labels the root element with the chosen name and accepts any prefix.
- No DTD or XSD generationThe tool does not generate a Document Type Definition or XML Schema. For a schema, derive one from the CSV header manually or use a separate tool to generate an XSD from a sample XML file.
Platform notes
- macOS
- For command-line work, `xmlstarlet` can convert CSV to XML with a small script. The browser tool is the right pick for one-off conversions where installing xmlstarlet through Homebrew is not worth the setup time.
- Windows
- PowerShell's `Import-Csv` and `Export-Clixml` cover the basics for PowerShell-only workflows. The browser tool is the right pick for cross-platform XML output that any XML parser can read, not just PowerShell.
- Linux
- The closest CLI equivalent is `python3 -c "import csv, xml.etree.ElementTree as ET; ..."` — a 5-line script that handles the conversion. The browser tool is the right pick for content pasted from a chat, an email, or a docs page.
- Web
- Runs entirely client-side. Works offline once the page has loaded. The XML output is portable — pipe it into any XML parser, XSLT transformer, or schema validator without dependencies.