Convert CSV to XML with your own element names and structure
The CSV to XML converter turns spreadsheet exports, database dumps and contact lists into XML for import tools, product feeds, configuration systems and web services. Paste CSV or TSV, or open a file saved from Excel or Google Sheets, and the XML appears as you type — one element per row and one child element, or attribute, per column.
It does more than wrap cells in tags. Column headers become legal XML names, a header such as @id becomes an attribute, address.city becomes a nested element and tags.tag.1, tags.tag.2 become repeated elements — so a flat file can still produce properly structured XML. Quoted fields with commas, doubled quotes and line breaks are read exactly as RFC 4180 describes.
The conversion runs in your browser, so the data in your spreadsheet is never uploaded.
How to use the CSV to XML Converter
- Paste CSV into CSV input or press Open file. The delimiter is detected automatically; choose comma, semicolon, tab or pipe to override it.
- Name the Root element and Row element, for example
productsandproduct. - Choose whether columns become child elements or attributes of each row, and whether empty cells become empty elements or are left out.
- Optionally add
typehints, and pick the indent and the XML declaration. - Press Copy or Download XML. Swap opens the result in the XML to CSV converter to check the round trip.
CSV to XML Converter features
Proper CSV parsing
Quoted fields can contain the delimiter, doubled quotes and line breaks. An unclosed quote is reported with the line where the field starts, instead of silently merging rows.
Headers become valid names
Unit Price becomes Unit_Price, 2nd phone becomes _2nd_phone, a duplicate header gets _2 and a blank one becomes column3. Or encode names reversibly as _x0020_.
Structure from flat columns
@id makes an attribute, address.city a nested element, address.@type an attribute on it, and tags.tag.1 plus tags.tag.2 two <tag> elements.
Elements or attributes
Write every column as a child element, or produce compact rows such as <row id="1" name="Asha"/>.
Empty cells and type hints
Keep empty cells as <notes/> or leave them out, and optionally mark numbers, true/false and ISO dates with type="number", "boolean", "date" or "dateTime".
Values copied exactly
CSV has no types, so 007, ₹499 and 1.50 appear in the XML exactly as written — nothing is rounded or reformatted.
From a CSV row to an XML element
Untick “Headers like a.b and @id nest and make attributes” to keep every header as one flat element name instead. Characters such as & and < in cells are escaped, and the whole document is checked with your browser’s XML parser before it is shown.
| CSV header | XML for one row |
|---|---|
name | <name>Priya Sharma</name> |
@id | the attribute id="1001" on <row> |
Unit Price | <Unit_Price>₹499.00</Unit_Price> |
address.street and address.pin | <address><street>…</street><pin>400020</pin></address> |
tags.tag.1 and tags.tag.2 | <tags><tag>books</tag><tag>music</tag></tags> |
| an empty cell | <notes/>, or nothing with “Leave out” |
Preparing a spreadsheet for XML
Going the other way? XML to CSV flattens XML records back into columns using the same naming rules. For JSON instead of XML, use CSV to JSON, and to pretty-print or validate an existing file, the XML Formatter.
- Save as “CSV UTF-8”. In Excel use File → Save As → CSV UTF-8 (Comma delimited), so ₹, £ and accented names survive. Google Sheets downloads CSV as UTF-8 already.
- Rename the headers first. Header names become element names, so make them match what the importing system expects —
sku,price,@currency. - One header row, one record per row. Merged cells, subtotal rows and second header rows do not survive CSV export and would become extra records.
- Use ISO dates. If the target schema uses
xs:date, format dates as2026-01-14before exporting.
CSV to XML Converter FAQ
How do I convert CSV to XML?
Paste the CSV or open the file, set the root and row element names, and press Download XML. The CSV to XML conversion updates live as you change any option.
How do I make a column an XML attribute?
Start its header with @, for example @id, and it becomes <row id="…">. To turn every column into an attribute, choose “Attributes of the row” under “Columns become”.
Can I create nested XML from a flat CSV file?
Yes. Dots in a header create nesting: address.city becomes <address><city>. A number as the last part, as in phones.phone.1 and phones.phone.2, creates repeated elements.
What happens to spaces and symbols in headers?
XML names cannot contain spaces or most punctuation, or start with a digit. They are replaced with underscores, or encoded as _xHHHH_ if you choose that option, which XML to CSV and XML to JSON decode back.
Does it work with semicolon or tab separated files?
Yes. Auto-detect recognises comma, semicolon, tab and pipe delimiters by looking for the one that gives every row the same number of columns.
Can I convert an Excel file to XML?
Save the sheet as CSV UTF-8 in Excel (or download it as CSV from Google Sheets), then open that file here. Each sheet needs its own CSV.
Is my CSV uploaded?
No. Parsing and conversion happen entirely in your browser, so customer lists and price files never leave your computer.