CSV to XML Converter

Turn CSV rows into well-formed XML. The first row gives the element names and every later row becomes a record. Runs in your browser.

Document Tools● Free No upload Instant

Loading CSV to XML Converter…

Your browser is preparing the tool. It runs 100% locally.

Quick answer

Paste CSV and get well-formed XML. The first row is read as headers and becomes the element names; each following row becomes a row element with one child per column. The whole thing is wrapped in a single rows root, with a UTF-8 XML declaration, and any reserved characters in your values are escaped. Your browser does the conversion, so the file is never uploaded.

What the CSV to XML Converter does

This converts comma-separated data into XML. The first line of your CSV is read as the column headers, and those header names become the XML element names. Each remaining line becomes one record.

The output is a complete, well-formed XML document: a UTF-8 declaration, a single rows root element, and a row element for every data line, each holding one child element per column.

How it works

Paste or type your CSV. The first row is parsed as headers, and the parser understands quoted fields and doubled quotes.

Each data row becomes a row element. For every column, the tool writes a child element named after the header, with the cell value inside. Spaces in a header are replaced with underscores so the element name is valid.

Values containing the ampersand, less-than or greater-than characters are escaped to their XML entities. Copy the result or download it as a .xml file. Everything happens in your browser.

Data source & conversion logic

  1. Parse the CSV. The text is parsed into rows, honouring quoted fields and doubled quotes inside them.
  2. Read the header row. The first row supplies the element names; any spaces in a header become underscores.
  3. Build the elements. Each later row becomes a row element with one escaped child element per column.
  4. Wrap and output. Everything is placed inside a single rows root under a UTF-8 declaration, ready to copy or download.

How each CSV row maps to XML

First CSV row = column headers = element names (spaces become underscores) Each later row = one <row> element Each cell = a child element named after its header Everything sits inside one <rows> document root
Worked example
The CSV name,age with rows Alice,30 and Bob,25 becomes a <rows> root holding two <row> elements, the first with <name>Alice</name> and <age>30</age>.

The wrapper names rows and row are fixed by the tool; only the column headers change the element names.

Privacy

Your browser parses and converts the CSV. There is no server, and the data is never uploaded.

The data never leaves your device, so even sensitive records stay private.

You don't need an account and the site keeps no copy, so the conversion is gone once you close the tab.

Technical details

InputCSV (first row = headers)
OutputWell-formed XML (.xml)
Root / recordrows / row (fixed names)
DeclarationUTF-8 XML prolog
EscapingAmpersand, less-than, greater-than
Data typesAll values are text
Processing100% in-browser

Standards & references

  • XML 1.0 (well-formed): Output is a well-formed XML document: one root element, properly nested and closed tags, a UTF-8 declaration.
  • XML element naming: Element names cannot contain spaces or start with a digit; the tool replaces spaces in headers with underscores, but other invalid characters are left as-is.
  • Predefined entities: The reserved characters ampersand, less-than and greater-than are escaped to their XML entities in element text.

Accuracy and limits

The first row must be your header row, because those names become the element tags. If your CSV has no header line, the first record is consumed as the headers.

Header sanitisation only replaces spaces with underscores. A header that starts with a digit or contains other characters XML forbids in a name (such as a slash, a bracket or the ampersand) would produce an element name XML rejects, so keep headers simple and alphanumeric.

Every value is written as element text, with no attributes and no data types. A number, a date and a word all come out as plain text inside an element.

The wrapper element names, rows and row, are fixed by the tool and not derived from your file. If you need different names, rename them in the output.

Empty cells become empty elements. Values are escaped for the ampersand, less-than and greater-than characters so the document stays well-formed.

Where people use it

Feed a legacy system

Convert a spreadsheet export into the XML an older API or import routine expects.

Quick XML sample

Turn a few rows of CSV into XML to test a parser or a stylesheet.

Config or data seed

Generate a simple XML data file from tabular data without writing code.

Inspect structure

See at a glance how your columns map to a nested element structure.

When it fits, and when it doesn't

Good for

  • Turning tabular CSV into simple, well-formed XML
  • Records where every field is a plain text element
  • Quick one-off conversions with simple headers

Not the best choice for

  • XML that needs attributes, namespaces or data types
  • Headers containing characters XML forbids in a name
  • Custom root or record element names

If you need attributes, typed values or custom element names, edit the output or use a dedicated XML mapping tool. To go the other way, use the XML to JSON converter and then JSON to CSV.

Frequently asked questions

Is the first row used as headers?
Yes. The first CSV row becomes the element names, and each later row becomes one record. If your file has no header line, the first record is taken as headers instead.
What are the root and record element names?
The document root is rows and each record is wrapped in a row element. Both names are fixed by the tool and are not taken from your data.
What happens to spaces in a header?
They are replaced with underscores, because an XML element name cannot contain a space. So a header of full name becomes the element full_name.
Can a header start with a number?
XML element names cannot start with a digit, so a header like 2024 would produce invalid XML. Rename such headers (for example to year_2024) before converting.
Does it escape special characters?
Yes. The ampersand, less-than and greater-than characters in your values are converted to their XML entities, so the output stays well-formed.
Are values typed as numbers or text?
Everything is element text. XML here carries no data types, so a number, a date and a word all appear as plain text inside their element.
Does it create attributes?
No. Every field becomes a child element, never an attribute. If you need attributes, you will have to edit the output.
Does it handle quoted CSV fields?
Yes. The parser understands quoted fields and a doubled quote inside a quoted field, so commas and line breaks within a quoted value are kept intact.
What happens to empty cells?
An empty cell becomes an empty element: an opening and closing tag with nothing between them.
Is the output well-formed XML?
Yes, provided your headers are valid XML names: a single root, properly nested and closed tags, and a UTF-8 declaration.
Is my data uploaded?
No. Your browser does the conversion, so the data never leaves your device.
How do I convert XML back to a table?
Use the XML to JSON converter, then the JSON to CSV converter to get tabular data again.

References

Builds XML in your browser from your CSV: the header row becomes element names (spaces turned into underscores), each data row becomes a row element, and the ampersand, less-than and greater-than characters in your values are escaped so the result stays well-formed. No copy goes to a server.

Popular

CSV to JSON Converter

CSV rows become a JSON array, keyed by the header row.

DocumentOpen
Popular

JSON to CSV Converter

Flatten a JSON array of objects into CSV columns.

DocumentOpen
Trending

Markdown to HTML

Turn everyday Markdown into clean HTML in your browser.

DocumentOpen

CSV to Excel Converter

Pasted CSV becomes a real .xlsx, with leading zeros kept.

DocumentOpen

Excel to CSV Converter

Pull the first sheet of a workbook out as plain CSV.

DocumentOpen

Excel to JSON Converter

Each spreadsheet row becomes a JSON object keyed by the header.

DocumentOpen

Back to the CSV to XML Converter

The file never leaves your computer, and you don't need an account.