How to Convert CSV to XML: Complete Guide
Last updated: 2026-04-14
CSV is a universal export format, but many enterprise systems, government portals, and legacy applications demand XML for data import. Whether you are submitting product feeds to an e-commerce marketplace, uploading financial records to a regulatory portal, or feeding data into an ETL pipeline that expects XML, the conversion from flat CSV rows to hierarchical XML elements is a recurring task.
Step-by-Step: Convert CSV to XML with Convertee
- Open Convertee and select CSV as source and XML as target.
- Paste your CSV data into the input panel, or drag-and-drop a
.csvfile. - Configure the XML output: root element name, row element name, delimiter, XML declaration, and indent style.
- Press Convert (Cmd+Enter).
- Copy the XML output or download it as an
.xmlfile.
The entire conversion happens in your browser using JavaScript. No CSV data is uploaded to any server — your files remain private.
Understanding the Formats
CSV
CSV (RFC 4180) stores tabular data as plain text. Each line represents a row, and fields within a row are separated by a delimiter (typically a comma). The first row usually contains column headers. CSV has no notion of data types, hierarchy, or metadata — every value is a string.
XML
XML (W3C XML 1.0) represents data as a tree of nested elements. Each CSV row maps naturally to an XML element, and each column becomes a child element within that row. XML supports attributes, namespaces, and schemas for validation — features that CSV lacks entirely.
Before / After Example
Input CSV:
country,capital,population
Japan,Tokyo,125800000
France,Paris,67390000
Brazil,Brasilia,214300000Output XML:
<?xml version="1.0" encoding="UTF-8"?>
<data>
<row>
<country>Japan</country>
<capital>Tokyo</capital>
<population>125800000</population>
</row>
<row>
<country>France</country>
<capital>Paris</capital>
<population>67390000</population>
</row>
<row>
<country>Brazil</country>
<capital>Brasilia</capital>
<population>214300000</population>
</row>
</data>Common Use Cases
- E-commerce product feeds. Marketplaces like Amazon Seller Central and Google Merchant Center accept XML product feeds. Exporting your catalog as CSV from a spreadsheet and converting to XML produces the upload file directly.
- Government and regulatory submissions. Tax filings, customs declarations, and public data submissions often require XML format. CSV exports from accounting software can be converted and mapped to the required XML schema.
- Legacy system integration. Older ERP and CRM systems that only accept XML imports can receive data originally exported from modern tools as CSV.
- Test fixture generation. When writing integration tests for an XML-based API, generating XML from a CSV spreadsheet of test cases is faster than hand-crafting each XML document.
Options and Configuration
| Option | Default | What It Does |
|---|---|---|
| Root element | data | Name of the outermost XML element that wraps all rows. |
| Row element | row | Name of the XML element representing each CSV row. Change it to match your target schema (e.g., product, record). |
| Delimiter | Comma (,) | The character that separates fields in your CSV. Switch to tab, semicolon, or pipe if needed. |
| XML declaration | On | Prepends the standard XML declaration header to the output. |
| Indent | 2 spaces | Controls indentation for readability. Choose 2 or 4 spaces, tabs, or minified. |
Frequently Asked Questions
- How does Convertee handle special characters in CSV values?
- Characters that are invalid in XML (like <, >, and &) are automatically escaped to their XML entities (<, >, &) so the output is always well-formed.
- Can I customize the XML element names?
- Yes. You can set both the root element name (wrapping the entire document) and the row element name (wrapping each record). Column header names from the CSV are used as child element names.
- What if my CSV column headers contain spaces or special characters?
- XML element names cannot contain spaces. Convertee replaces spaces with underscores and removes characters that are invalid in XML element names to ensure well-formed output.
- Is my CSV data sent to a server during conversion?
- No. The conversion runs entirely in your browser using client-side JavaScript. Your CSV data stays on your machine.