How to convert CSV to XML
Load a CSV, TSV, or TXT file, set the parsing options, then map each column to a child element, an attribute on the row, or omit it. The converter reports XML name changes and shows the generated XML before you download it.
- Choose File encoding and load CSV, TSV, or TXT files.
- Set Delimiter, Quote character, Escape style, and First row is a header.
- Set Root element name and Row element name, then choose a target for each column.
- Choose Empty / missing values, Indentation, and Include XML declaration.
- Review the previews and select Download converted files.
CSV to XML column mapping
The column mapping table shows each parsed header and its target. Choose Child element, Attribute on row, or Omit from output. A custom element/attribute name replaces the header before the converter sanitizes it.
name,age
Alice,34
<?xml version="1.0" encoding="UTF-8"?>
<records>
<record>
<name>Alice</name>
<age>34</age>
</record>
</records>
Root element name and Row element name start as records and record. Characters outside the allowed XML name pattern become underscores. Names that start with a digit or with xml receive a leading underscore, and duplicate names receive suffixes such as name_2. A header such as address.city remains one flat field.
Convert TSV to XML with parsing and empty-value controls
Delimiter supports Auto-detect, Comma (,), Semicolon (;), Tab, Pipe (|), and Custom... File encoding supports Auto-detect (BOM / UTF-8), UTF-8, UTF-16 LE, UTF-16 BE, Windows-1252, and ISO-8859-1. Quote character and Escape style control how quoted fields are read.
When First row is a header is cleared, the converter creates names such as field1 and field2. Missing cells become empty values, and extra cells are ignored. Parser issues include line numbers for stray or unfinished quotes and rows whose widths differ from the header.
For an empty Child element value, Empty / missing values can produce an empty element, a self-closing element, xsi:nil="true", or omission. Empty attributes stay empty unless Omit entirely is selected. Indentation supports 2 spaces, 4 spaces, Tab, or Minified (no whitespace).
Review the XML preview before downloading
Source data preview shows the first 20 rows. Generated XML preview refreshes with the mapping and formatting choices. If the XML is longer than 20,000 characters, the displayed preview is truncated, while the downloaded file remains complete. Clear Include XML declaration to remove the declaration.
The page reads selected files with browser FileReader and builds each XML download with a browser Blob. The converter keeps flat rows flat, so a dotted header does not create nested XML. XML 1.0 control characters are kept and flagged; validate the output when that warning appears.
When several files are loaded, the mapping comes from the selected Previewing file and is reused for every file. A different header layout can therefore map the wrong columns. Review each file before selecting Download converted files.
Where this comes up
- A developer turns a small CSV export into row-based XML for a system that expects named elements.
- An analyst maps identifiers to row attributes and leaves descriptive columns as child elements.
- A data workflow starts with TSV files, then uses the XML preview to check names and empty fields before saving.
Choose the right spreadsheet converter
Spreadsheet Convert Tools covers related table conversions. Use CSV JSON Converter when the destination is JSON or the data contains nested objects and arrays. Use CSV to Excel Converter when you need an XLSX workbook or multiple sheets. Use Delimiter Converter when you need another delimited text format and want to control quoting, headers, and null values.
Frequently asked questions
Can I convert TSV to XML?
Yes. Load the TSV file and choose Tab under Delimiter, or leave Auto-detect selected.
How do I convert a CSV column to an XML attribute?
Choose Attribute on row in the column mapping for that field. The value is written on the row element, while other columns can remain Child element targets.
Does CSV to XML create nested elements from dotted headers?
No. A header such as address.city becomes one sanitized element or attribute name, not a nested path.