CSV to XML
Turn CSV rows into well-formed XML elements.
CSV to XML Converter Online
The CSV to XML converter wraps every row of a comma-separated file in an XML element, using the header row for the tag names. It is the quickest way to feed spreadsheet data into systems that only speak XML: legacy SOAP services, product feeds, ERP imports, Android resources, or an XSLT pipeline.
How the conversion works
- The CSV is parsed with an RFC 4180 parser, so quoted commas and line breaks survive.
- Each data row becomes one row element inside a single root element.
- Each column becomes a child element (or an attribute) named after its header.
With the sample data you get <rows> containing five <row> elements, each with <id>, <name>, <email>, and so on.
Options
- Root element / Row element – rename the wrappers, e.g.
customersandcustomer, to match the schema you are targeting. - Columns as attributes – write
<customer id="1" city="London"/>instead of nested child elements. - Indentation – two or four spaces, tabs, or a single compact line for transport.
- XML declaration – include or omit the
<?xml version="1.0" encoding="UTF-8"?>line, for example when the fragment will be pasted inside another document. - First row is a header – turn off for header-less files; columns are then called
column1,column2…
Edge cases
Empty cells produce empty elements, duplicate headers are made unique (name, name_2), and short rows are padded. Header names are sanitised into valid XML names so the result always parses. A table preview below the editor shows how the rows were read before you copy the XML.
When to choose XML over JSON
XML is still required by many B2B integrations, government portals, and publishing systems, and it supports schemas, namespaces, and XSLT. If your target is a modern web API, CSV to JSON is usually a better fit — or use CSV to XML/JSON to produce both from one input.
Related tools
Check the result in the XML Validator, explore it in the XML Viewer, or transform it further with the XSLT tool. For the reverse direction, use XML to CSV.
Frequently Asked Questions
How are CSV column names turned into XML tags?
Each header becomes an element name. Characters that are not allowed in XML names, such as spaces or slashes, are replaced with underscores, and a name that starts with a digit gets a leading underscore — so “unit price” becomes <unit_price> and “2024” becomes <_2024>.
Should I use elements or attributes?
Elements (the default) are easier to extend and can hold long or multi-line text. Switch on “Columns as attributes” for a compact one-line-per-row format like <row id="1" name="Jane"/>, which many import tools and config files prefer.
Are special characters escaped?
Yes. Ampersands, less-than and greater-than signs, and quotes inside cells are written as XML entities, so the output is always well-formed no matter what the CSV contains.
What does “Detect numbers & booleans” change in XML?
XML text has no types, but with the option on, values are normalised the way a JSON conversion would treat them: 007 stays as written, 1.50 becomes 1.5, and TRUE becomes true. Leave it off to copy every cell exactly as it appears in the CSV.