SmartQueryTools

Convert CSV to XML Online

Convert CSV files to XML directly in your browser. Download a structured XML document with one element per row — no upload required.

About converting CSV to XML

XML is still the input format for a lot of enterprise and government software: ERP and accounting imports, EDI middleware, product feeds, e-invoicing gateways and older SOAP services. Converting CSV to XML is usually the first step toward one of those systems, or toward an XSLT stylesheet that reshapes the records into the schema the target expects.

The output is a generic, predictable structure. There is an XML declaration, a <data> root, one <row> element per CSV row, and one child element per column holding the value as text. It is well-formed and easy to transform, but it will rarely match a vendor schema as it stands. Plan on an XSLT or a short script to rename elements and add attributes or namespaces.

Headers are the usual problem. XML element names cannot contain spaces or most punctuation, and cannot start with a digit. The converter replaces every character other than ASCII letters, digits and underscores with an underscore, and adds a leading underscore to names that start with a digit. So "Order Date" becomes Order_Date, "2025 sales" becomes _2025_sales and "prénom" becomes pr_nom. Rename columns in the CSV first if exact element names matter.

Worked example

A small orders export with an ID, a customer name, a date, an amount (one missing) and a true/false flag, converted with the default settings.

Input (CSV)

order_id,customer,order_date,amount,shipped
1001,Acme Ltd,2026-03-02,249.5,true
1002,Brightside Co,2026-03-02,1200,false
1003,Acme Ltd,2026-03-05,89.99,true
1004,Northwind,2026-03-07,,false

Output (XML)

<?xml version="1.0" encoding="UTF-8"?>
<data>
  <row>
    <order_id>1001</order_id>
    <customer>Acme Ltd</customer>
    <order_date>2026-03-02</order_date>
    <amount>249.5</amount>
    <shipped>true</shipped>
  </row>
  <row>
    <order_id>1002</order_id>
    <customer>Brightside Co</customer>
    <order_date>2026-03-02</order_date>
    <amount>1200</amount>
    <shipped>false</shipped>
  </row>
  <row>
    <order_id>1003</order_id>
    <customer>Acme Ltd</customer>
    <order_date>2026-03-05</order_date>
    <amount>89.99</amount>
    <shipped>true</shipped>
  </row>
  <row>
    <order_id>1004</order_id>
    <customer>Northwind</customer>
    <order_date>2026-03-07</order_date>
    <amount></amount>
    <shipped>false</shipped>
  </row>
</data>

What changes when you convert CSV to XML

  • The file opens with <?xml version="1.0" encoding="UTF-8"?> and wraps everything in a <data> root element.
  • Each CSV row becomes a <row> element, and each column becomes a child element named after its header, such as <order_id> and <customer>.
  • Every value is text. XML carries no types, so 249.5, true and 2026-03-02 are all plain character data.
  • Order 1004's missing amount is written as an empty <amount></amount>. There is no xsi:nil attribute, so an empty element is the only sign of a missing value.
  • The characters & < > " and ' are escaped as entities, so a value like "Smith & Co" keeps the file well-formed.

Your file is processed locally in your browser and is never uploaded. The free limit is 50 MB per file; larger files work if your device has the memory for them.

Frequently Asked Questions

Can I put the values in attributes instead of child elements?

Not in this converter. Each value is always a child element. An XSLT stylesheet can move them into attributes in one pass, producing elements like <order id="1001" customer="Acme Ltd"/>.

How do I change the <data> and <row> element names?

They are fixed. Rename them afterwards with a find and replace on the opening and closing tags, or with an XSLT identity transform that renames just those two elements. Column element names come from the CSV header, so rename those columns before converting.

Is the output valid against an XSD?

It is well-formed XML, but no schema is generated or referenced. If the destination system validates against its own XSD, transform the structure to match it first.

Related Tools