CSV to XML Converter Online — Generate XML from CSV

Wrap each CSV row as an XML record element with header-named children, escape special characters, and produce well-formed XML ready for EDI, SOAP, XSLT, or any XML-aware system.

What is a CSV to XML converter?

A CSV to XML converter reads tabular CSV data and emits well-formed XML — wrapping each row in a <record> element and turning each header into a child element name. The OpenFormatter version sanitises headers, escapes XML special characters, and adds the <?xml version="1.0"?> declaration so the output is parseable by any XML library or EDI gateway.

Despite the rise of JSON, XML still drives huge swathes of enterprise integration: EDI in retail and supply chain, HL7 in healthcare, SOAP services in banking, OFX in finance, and government standards like NIEM. Most of those systems accept XML over the wire but never CSV — so the natural shape of the conversion is "export tabular data, wrap as XML, send."

How to convert CSV to XML online — 4 steps

  1. Paste your CSV. Use the first row for headers — those become XML element names.
  2. Click Convert. Each row is wrapped in <record> with header-named children. Special characters in cell values are entity-escaped.
  3. Verify well-formedness. Output starts with the XML declaration. Drop it into a browser or IDE — it should parse without error.
  4. Rename if needed. Find-and-replace <records> with your domain root and <record> with your row tag (e.g. <orders> / <order>).

Sample CSV and XML output

A small product CSV with a quoted comma and a special character — note how & and the comma are handled:

Input CSV

sku,product,price,in_stock
A-101,Widget Pro,29.99,true
A-102,"Bracket, Heavy",14.50,true
A-103,Gear Kit,9.95,false

XML Output

<?xml version="1.0" encoding="UTF-8"?>
<records>
  <record>
    <sku>A-101</sku>
    <product>Widget Pro</product>
    <price>29.99</price>
    <in_stock>true</in_stock>
  </record>
  <record>
    <sku>A-102</sku>
    <product>Bracket, Heavy</product>
    <price>14.50</price>
    <in_stock>true</in_stock>
  </record>
  <record>
    <sku>A-103</sku>
    <product>Gear Kit</product>
    <price>9.95</price>
    <in_stock>false</in_stock>
  </record>
</records>

Header → Element

Each CSV header becomes the tag name of a child element. Names with spaces or hyphens are sanitised so the output is always a valid XML tag.

Escape-Safe Output

Cell values containing &, <, >, ", or single quotes are converted to entity references so the XML always parses cleanly.

Browser-Only

CSV is parsed in JavaScript on your machine. Order data, customer records, and EDI payloads never leave your device.

Common use cases

  • check_circleGenerating XML for EDI gateways (X12, EDIFACT) from a CSV order export
  • check_circleConverting CSV product feeds to XML for retailers that ingest XML only
  • check_circleCreating SOAP request bodies from spreadsheet data for legacy integrations
  • check_circleBuilding XML fixtures for XSLT transformations and unit tests
  • check_circleLoading CSV data into XML-native databases like BaseX or eXist-db
  • check_circleProducing XML sitemaps and feeds from CSV content schedules
  • check_circlePreparing CSV records for Salesforce, SAP, and other XML-based ERPs
  • check_circleConverting CSV financial data to OFX, FpML, or XBRL drafts

XML vs JSON for tabular data

For pure tabular data, JSON is more compact and faster for JavaScript clients to parse. XML wins when the consumer expects schema validation (XSD), namespaced elements, or document-oriented operations like XPath and XSLT — all of which JSON lacks. Pick CSV→XML when integrating with EDI, SOAP, or any system whose API contract is an XML schema; pick CSV→JSON when the target is a REST API, MongoDB, or a JavaScript front-end. The OpenFormatter site offers both — same input, different output.

Need a different output format?

The same CSV can become JSON, YAML, or an HTML table — pick what your downstream system expects.

Frequently Asked Questions

What root and row element names does the converter use?

The output wraps the entire document in a <records> root and uses <record> for each row. These names are deliberately generic so the XML is valid against most consumers; once converted you can find-and-replace the root or rename <record> to a domain-specific tag like <product> or <order>.

How are CSV headers turned into XML?

Each header becomes the tag name of a child element inside <record>, with the cell value as the text content. So "name" in the header row produces <name>Ada</name> in every record. The converter sanitises header names that are not valid XML tags (e.g. "first name" with a space becomes first_name).

Does the output escape special characters like &, <, >, " correctly?

Yes. Cell values containing &, <, >, ", or ' are replaced with &amp;, &lt;, &gt;, &quot;, and &apos; before being written into the XML. This guarantees the output is well-formed and parseable by any XML library.

Can I make a header an XML attribute instead of a child element?

This converter emits children only — the most portable choice for attribute-agnostic consumers like XSLT and XML databases. To convert a child to an attribute (e.g. <record id="1">), run a quick search-and-replace on the output, or use an XSLT transform if you have one in your pipeline.

What XML declaration is included?

The output starts with <?xml version="1.0" encoding="UTF-8"?> on the first line. UTF-8 is the universal default and matches what most modern parsers, EDI gateways, and SOAP services expect.

Will the XML validate against an XSD schema?

Schema validation is separate from well-formedness. This tool produces well-formed XML — it parses cleanly. To validate against an XSD (e.g. an EDIFACT, HR-XML, or industry standard schema), pipe the output through xmllint --schema or an XML-aware editor like Oxygen.

Is my CSV uploaded to your server?

No. Conversion runs in JavaScript inside your browser. Customer records, order data, and PII never leave the device. Open DevTools → Network and verify zero requests are sent when you click Convert.

How do I rename the root element to something domain-specific?

After converting, replace the two occurrences of <records> with your preferred root tag (e.g. <orders> and </orders>) and replace <record> with <order>. A 4-keystroke find-and-replace covers it.

CSV to XML Converter Online — Generate XML from CSV