CSV Tools Your file never leaves your computer.

CSV to XML

Drop your CSV below to get XML. The conversion happens inside this browser tab, so the file is never uploaded to a server.

How to convert CSV to XML

  1. Choose your CSV file, or drag it onto the box below.
  2. Optionally set the root and row element names.
  3. Download the XML.

Why element names get rewritten

XML has strict rules for names: no spaces, no leading digits, and a limited character set. CSV headers have no rules at all. Rather than emitting a file that fails to parse, invalid characters are replaced with underscores and a leading underscore is added where a name starts with a digit.

A declaration is always included

Output starts with an XML declaration specifying UTF-8, so the encoding is stated rather than guessed by whatever reads the file next.

Questions

What if my column names are not valid XML element names?

They are corrected rather than rejected. XML names cannot contain spaces or start with a digit, so "first name" becomes first_name and "2nd" becomes _2nd. Without this the output would be a file no XML parser could read.

Are special characters escaped?

Yes. Ampersands, angle brackets and quotes are escaped, so values containing markup or company names such as "Smith & Sons" produce valid XML rather than a parse error.

Can I choose the element names?

Yes. The root defaults to <rows> and each record to <row>; both can be set before converting. They are validated the same way column names are.

Is my file uploaded anywhere?

No. The XML is generated in JavaScript inside your own browser tab. Nothing is sent to a server, stored or logged.

Are attributes used instead of child elements?

No. Every column becomes a child element, which handles values of any length and any content once escaped. Attributes are more compact but cannot hold multi-line values.

Background

For why CSV files lose leading zeros, arrive as one long column, or show strange characters, see what a CSV file is. This page is one of the free CSV converter tools — all of them run in your browser and none of them upload your file.

Other tools