A CSV to XML converter turns a spreadsheet export or any comma-separated file into well-formed XML. Paste your CSV, and this CSV to XML converter reads the first row as column names, wraps each record in a row element and each value in an element named after its column, or writes the values as attributes if you prefer. It handles quoted fields with commas and line breaks, detects the separator, and escapes special characters, so the XML is ready to use.
How to use the CSV to XML converter
- Paste your CSV data.
- Check the separator. Detect automatically works for commas, tabs, semicolons and pipes.
- Say whether the first row holds column names or data.
- Choose elements or attributes for the fields, and, if you like, names for the root and row elements.
- Press Convert to XML, then copy or download the result.
What CSV is
Comma-separated values, CSV, is a plain-text format for tabular data: each line is a record and the fields in it are separated by commas. It's what spreadsheets and databases export most often. The format is described in RFC 4180, which says that a field containing a comma, a double quote or a line break should be enclosed in double quotes, and that a double quote inside a quoted field is written as two double quotes. That's why CSV can't be read by simply splitting lines at commas, and why this converter uses a proper parser.
What XML is
XML, the Extensible Markup Language, is a W3C format for structured data. A well-formed XML document has a single root element that contains all the others, tag names that match exactly, including case, and special characters written as entities: < for <, > for >, & for &, " for a double quote and ' for an apostrophe. Tag names can't contain spaces or most punctuation and can't start with a digit, a hyphen or a period.
Worked example
This CSV:
name,age,cityJane Doe,34,"Portland, OR"Sam Lee,28,Austin
becomes, with fields as elements:
<?xml version="1.0" encoding="UTF-8"?><rows> <row> <name>Jane Doe</name> <age>34</age> <city>Portland, OR</city> </row> <row> <name>Sam Lee</name> <age>28</age> <city>Austin</city> </row></rows>
With fields as attributes, each record is one line: <row name="Jane Doe" age="34" city="Portland, OR"/>. The comma inside the quoted city stays part of the value.
Elements or attributes?
Elements are the more flexible choice: they can hold long text and line breaks, and most systems that import XML expect them. Attributes make a much more compact file, with one line per record, which is easy to read when every value is short. Both describe exactly the same data, so pick whichever the program you're feeding expects.
How column names become tag names
Spreadsheet headings often contain spaces or symbols, which aren't allowed in XML names. The converter replaces spaces and forbidden punctuation with underscores and puts an underscore in front of a name that starts with a digit, hyphen or period, so First Name becomes First_Name and 2024 Sales becomes _2024_Sales. A blank heading becomes column1, column2 and so on, and a repeated heading gets a number, so every field keeps a name of its own. If the first row is data, the columns are named column1, column2 and onward.
Special characters
Ampersands and angle brackets in your data are written as entities, so a value such as Fish & Chips doesn't break the XML. In attribute mode, double quotes and line breaks inside values are escaped too. Empty fields become empty elements like <city/>, or empty attributes, so every record has the same structure.
Where CSV to XML conversion helps
- Importing data into systems, feeds and content tools that only accept XML.
- Product feeds built from a spreadsheet of items.
- Configuration and test data kept in a spreadsheet but needed as XML.
- Data exchange with older enterprise software.
To check the result, paste it into the XML validator.
Is my data private?
Yes. The conversion runs in your browser, so the CSV you paste is never uploaded.
Large files
You can paste up to five million characters, enough for tens of thousands of rows. For a very large export, convert it here, download the .xml file, and open it in a code editor rather than copying it by hand.
Common mistakes
- Unclosed quotes. A stray double quote can swallow the rest of the file; the tool warns you.
- Wrong separator. Files from European spreadsheets often use semicolons.
- Treating a header row as data, or the other way round.
What next
Use this often? Add CSV to XML to your Home screen.
Frequently asked questions
How does the CSV to XML converter work?
It parses the CSV following RFC 4180, uses the first row as tag names, and writes each record as a row element with escaped values.
Can the XML use attributes instead of elements?
Yes. Choose Attributes to write each record as one element with the fields as attributes.
What happens to commas inside quoted fields?
They stay part of the value. Quoted fields can also hold line breaks and doubled quotes.
What if my column names have spaces?
Spaces and symbols become underscores, so the names are valid XML.
Is my CSV uploaded?
No. It's converted in your browser.
Was this tool helpful?
What went wrong?
We only receive the reason you pick, never what you typed into the tool.
Thanks for your feedback.