CSV to XML
Convert CSV to valid XML in your browser. Column names become legal element names, values are escaped, and nothing is uploaded.
Related tools
All Data tools →This tool runs entirely in your browser. Nothing you enter is sent to our servers, so there is nothing for us to store or see.
About the CSV to XML
Paste CSV and get well-formed XML back as you type. Everything runs inside this page on your own device, so nothing you paste is uploaded.
The part that needs care is element names, because XML is far stricter about them than a spreadsheet heading ever is. A name cannot begin with a digit, cannot contain a space or most punctuation, and cannot begin with the letters xml in any casing — that prefix is reserved by the specification. A column called 2024 Total (£) is a perfectly ordinary heading and an illegal element name, so headings are converted into legal names rather than emitted as-is to produce a document no parser will open.
Duplicate names are resolved too, which matters most in attribute mode: two attributes with the same name on one element is not merely untidy, it is a fatal error that makes the whole document unparseable. Values are escaped for ampersands, angle brackets and quotes, and control characters that XML 1.0 cannot represent at all are dropped rather than encoded — a numeric reference to one produces a document every parser rejects.
You can put each field in its own child element, which is the readable default, or as attributes on the row element, which produces a much smaller document. The root and row element names are yours to set, and the XML declaration is optional for when the result is being embedded in a larger document.
How to use the CSV to XML
-
Paste your CSV
Paste into the left pane, or drop a .csv file onto it — dropping reads the file locally and never uploads it.
-
Name the root and row elements
The defaults are rows and row. Anything you type is converted to a legal XML name, so a space or a leading digit will not produce a broken document.
-
Choose elements or attributes
Child elements are readable and handle any value. Attributes produce a far smaller document, which matters for a large export.
-
Copy or download
The XML appears on the right as you type. Copy it, or download it as a .xml file.
Frequently asked questions
Is my data uploaded anywhere?
No. The conversion runs inside your browser and nothing is sent to a server. You can disconnect from the internet once the page has loaded and it will keep working exactly as before.
What happens to a column heading that is not a legal element name?
It is converted into one. Illegal characters become underscores, leading digits and punctuation are removed, and a name starting with the reserved prefix "xml" is prefixed with an underscore. A heading like "2024 Total (£)" is ordinary in a spreadsheet and illegal in XML, so emitting it as-is would produce a document no parser will open.
Why does it rename my duplicate columns?
Because in attribute mode two attributes with the same name on one element is a fatal parse error, not a cosmetic problem — the whole document becomes unreadable. Later duplicates are suffixed so every name is distinct, which also keeps element mode unambiguous.
Are special characters handled?
Ampersands, angle brackets and quotation marks are escaped, with the ampersand handled first so the escaping cannot be applied twice. Control characters that XML 1.0 cannot represent are dropped instead of encoded, because a numeric reference to one produces a document that every parser rejects.
Should I use elements or attributes?
Elements are the readable default and cope with any value, including ones containing line breaks. Attributes produce a considerably smaller file, which is worth having on a large export — the trade is that attributes are harder to read and conventionally used for metadata rather than content.