All tools
Free · Private · No upload

Convert CSV to XML Online

Turn CSV rows into XML: one element per row, and one child element (or attribute) per column. The CSV is read in your browser and never uploaded.

Drop a CSV or Excel file here

CSV · XLSX · XLS · XLSM · XLSB

or paste your data below

How to convert CSV to XML

Three steps from feed.csv to XML.

1. Paste or drop the CSV

Paste CSV text or drop a .csv, .tsv or .txt file; the delimiter is detected.

2. Check it in the grid

Check headers for spaces and symbols: they become tag names. Rename them here if the XML must match an existing format.

3. Name the tags

Set the root and row tag names, choose elements or attributes, toggle pretty printing, then copy or download data.xml.

Example: CSV in, XML out

A product feed with a spaced header ("Product ID") and an ampersand in a title.

feed.csv
Product ID,Title,Price,Availability
SKU-1,Desk lamp,24.00,in stock
SKU-2,Chair & cushion,89.50,out of stock
data.xml (default options)
<?xml version="1.0" encoding="UTF-8"?>
<rows>
  <row>
    <Product_ID>SKU-1</Product_ID>
    <Title>Desk lamp</Title>
    <Price>24.00</Price>
    <Availability>in stock</Availability>
  </row>
  <row>
    <Product_ID>SKU-2</Product_ID>
    <Title>Chair &amp; cushion</Title>
    <Price>89.50</Price>
    <Availability>out of stock</Availability>
  </row>
</rows>

"Product ID" becomes the element <Product_ID>, and the & in Chair & cushion is written as &amp;.

What changes between CSV and XML

Structure

An XML declaration, a <rows> root, one <row> per data row and one child element per column. Root and row names are editable; characters that aren't allowed are replaced with _.

Tag names come from headers

Column elements are named after the headers, made safe for XML: "Product ID" becomes <Product_ID>. A header starting with a digit gets a col_ prefix.

Detected delimiter: comma

The page counts commas, semicolons, tabs and pipes in the first line and splits on whichever appears most: 3 commas here. Quoted fields keep their delimiters and line breaks inside one cell.

When to convert CSV to XML

CSV to XML in JavaScript

TabularJS reads the CSV into a 2D array. Then headers become tag names and values are escaped for XML.

import tabularjs from 'tabularjs';

// CSV values are strings; the header row stays in data[0]
const { worksheets } = await tabularjs('feed.csv');
const [header, ...rows] = worksheets[0].data;

const tag = (h) => String(h).trim().replace(/[^A-Za-z0-9_]/g, '_');
const esc = (v) => String(v ?? '').replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
console.log('<?xml version="1.0" encoding="UTF-8"?>\n<rows>\n' + rows.map((row) =>
  '  <row>\n' + header.map((h, i) => `    <${tag(h)}>${esc(row[i])}</${tag(h)}>`).join('\n') + '\n  </row>'
).join('\n') + '\n</rows>');

TabularJS returns CSV values as strings and leaves the header in data[0]. It does not guess the delimiter: comma is the default, so pass { delimiter: ';' } for semicolon files.

npm install tabularjs MIT licensed

Frequently asked questions

Can I set my own root and row names, like products and product?

Yes. Type them into the Root tag and Row tag boxes. Invalid characters are replaced with _, and an empty box falls back to rows and row.

Is the column order kept?

Yes. Child elements follow the column order of the CSV, and rows keep their order too. Reorder or delete columns in the grid if the receiver expects something else.

Can I convert a TSV file?

Yes. Drop the .tsv file or paste its text: tabs in the first line are detected as the delimiter, just like commas or semicolons.

Can I change the tag names?

Yes. Type a root tag and a row tag (for example feed and feed). Column element names come from the header row, so rename headers in the grid to change them.

Does feed.csv get uploaded when I convert it to XML?

No. The CSV is read in your browser and never uploaded.