Convert CSV to XML

Convert CSV to XML with custom tag names, element/attribute modes, CDATA wrap, headerless mode. Free, offline, client-side, instant.

Convert CSV/TSV to XML with 2 output modes (child elements or attribute style), CDATA wrap for HTML cell values, custom root + row tag names, delimiter auto-detect, headerless mode, and proper XML-name validation.

How to Use Convert CSV to XML

  1. Paste CSV into the input pane, upload a .csv/.tsv file, or click Load sample.
  2. Pick a delimiter (auto-detect handles comma/semicolon/tab/pipe).
  3. Customize tag names: root tag wraps the whole document, row tag wraps each record. Invalid characters auto-replaced; names starting with digits auto-prepended with _.
  4. Pick output mode: child elements (each column becomes a nested element) or attribute style (each column becomes an attribute on a self-closing element - more compact).
  5. Toggle CDATA wrap if cell values contain HTML/markup - prevents the parser from interpreting <p> as an XML tag.
  6. Toggle XML declaration (the <?xml ?> line) - turn off if embedding in another XML document.
  7. Pick indent (2/4/tab) and click Copy or Download data.xml.

Frequently Asked Questions

What’s the difference between element and attribute modes?

Child elements: <row><name>X</name><age>30</age></row> – verbose but human-readable. Attribute style: <row name="X" age="30"/> – half the bytes, faster parse, but loses the ability to nest complex content inside a field. Use elements for documents with rich text; attributes for compact data exchange.

When should I use CDATA?

When cell values contain HTML, XML, JavaScript, or any text with <, >, & that you want preserved EXACTLY without entity-escaping. Without CDATA: <bio>&lt;p&gt;Hello&lt;/p&gt;</bio>. With CDATA: <bio><![CDATA[<p>Hello</p>]]></bio>. The CDATA wrapper makes the original markup readable when humans inspect the XML.

How are invalid XML names handled?

XML element names must start with a letter or underscore and contain only letters, digits, hyphens, underscores, periods. Headers with spaces (First Name) become First_Name. Headers starting with digits (1st Place) become _1st_Place. Duplicate header names auto-suffix to -2, -3. The tool sanitizes silently to keep the output well-formed.

What’s the XML declaration for?

The <?xml version="1.0" encoding="UTF-8"?> line declares the XML version and character encoding. Standalone XML files should include it; XML fragments embedded inside larger documents typically shouldn’t (you can’t nest declarations). Turn it off when generating XML for inclusion via XSLT, XInclude, or similar.

Does it handle quoted commas?

Yes – RFC 4180 compliant. "Williams, Joe" stays as one cell. Also handles escaped quotes ("" = literal "), embedded newlines in quoted cells, and BOM at file start.

What if cells contain XML special characters?

Without CDATA: < becomes &lt;, > becomes &gt;, & becomes &amp;, single quote becomes &apos;, double quote becomes &quot;. All 5 standard entity references. With CDATA: preserved verbatim (but the wrapper escapes nested ]]> sequences).

Why not just JSON?

XML excels at: enterprise integrations (SOAP, SAML, OAuth XML profiles), document formats (SVG, RSS, XHTML, OOXML, ODF), config files (Maven pom.xml, Android XML), and any domain with mature XSD schemas. JSON wins for REST APIs and modern web. CSV-to-XML is most needed for legacy systems, B2B EDI, and government data feeds where XML is the required interchange format.

Is there schema validation?

Not in this tool – output is just well-formed XML (correctly nested, escaped, declared). Schema validation (XSD/DTD/RelaxNG) is a separate concern requiring a schema file. For validation, paste the output into xmlvalidation.com or use a CLI tool like xmllint --schema.

Is my data secure?

Yes. CSV input + uploaded files + generated XML all stay in your browser. Nothing is uploaded to any server.