How to use it
- Choose a CSV or TSV file, drop it on the box, or paste the text; the result appears at once.
- Check the delimiter and the header option; the notes next to the result show what was detected.
- Set the names of the root and row elements, and turn on “Nest dotted headers” if you want nested XML.
- Download the .xml file or copy the result.
Rules and limits
How CSV is read
- Delimiter: comma, semicolon, tab or vertical bar, detected from the first rows, or set by you.
- Fields in double quotes may contain the delimiter, line breaks and quotes written as two quotes (
""), as in RFC 4180. Line endings CRLF, LF and CR all work. Completely empty lines are skipped. - Encoding: UTF-8 with or without a byte order mark, and UTF-16 with a byte order mark. A file that is not valid UTF-8 is read as Windows-1251 when its letters look Cyrillic, otherwise as Windows-1252, and the result names the encoding. Files that are not text (a workbook, a Word document, a PDF, a picture, a gzip file or other binary data) are refused with a message that says what they are.
- Numbers, in CSV to JSON and CSV to Excel: with the decimal separator on “Automatic”, a comma is used when the delimiter is a semicolon (the usual European CSV), otherwise a dot. With a decimal comma, spaces between groups of three digits are read as thousands separators (
1 299,50). A dot or comma as thousands separator is not recognised, because1.234can mean 1234 or 1.234: such values stay text unless their dot or comma is the decimal separator. Values with leading zeros (01067), a leading plus sign (phone numbers) or more than 15 digits stay text.
From CSV to XML
- With “First row is a header” on, each header becomes the name of a child element.
- Header names that are not valid XML names are adjusted: spaces and other invalid characters become “_”. A header that starts with “@” becomes an attribute.
- Each data row becomes one element (default
<row>) inside the root element (default<rows>). Values are written exactly as text; an empty field gives an empty element such as<note/>. - Every row gets every column: a row with more fields than the header adds elements named
column_Nto all rows, and a warning names the first row whose field count differs from the header. - With “Nest dotted headers” on,
address.citybecomes<address><city>…</city></address>. The XML declaration is always written.
Questions and answers
Why are numbers written as plain text?
XML has no number type: every value is text, so the page writes it exactly as it is in the CSV, with its zeros, signs and separators.
Why do some element names differ from my headers?
XML names cannot contain spaces and some other characters, so they become “_”. Rename the headers in the CSV file to choose the names yourself.
What if my CSV has no header row?
Turn off “First row is a header”: the elements are then named column_1, column_2 and so on. Rename them later, or add a header row to the file.
Why does a row get extra elements named column_N?
That row has more fields than the header, often because a value contains the delimiter but is not in quotes. Put such values in double quotes, or choose the right delimiter.