TinyCSV LogoTinyCSV

CSV to XML Converter

Convert CSV records to XML. Choose the root and record elements, map columns to elements or attributes, review name conflicts and empty values, then inspect the result before downloading.

Last updated

Drop a CSV here, paste rows, or try the example.

Your original data is not changed by previewing.

Key Features

Map columns explicitly

Choose which columns become child elements, which become attributes on the record, and which are excluded. Output names can be edited and reordered.

See name conflicts

Invalid XML names, duplicate output names, and a root that matches the record name are listed before generation instead of being silently renamed.

Keep values as text

Leading zeros, long identifiers, date-like strings, quotes, commas, and line breaks inside cells are escaped rather than reinterpreted as another type.

Sample and full stay separate

The on-page XML is a labeled sample. Full processing generates the document you download or pass to another tool.

How to Use

  1. 1

    Choose a CSV file or paste data

    Open a CSV file, paste records, or start with the example. Check the delimiter, header row, and encoding in the input settings before mapping columns.

  2. 2

    Set the root and record names

    Every CSV record becomes one record element inside a single root element. Names must be valid XML names and cannot be the same.

  3. 3

    Map the columns

    For each column, choose an element, an attribute, or Exclude, and set its output name. Resolve any invalid or duplicate names shown in the mapping panel.

  4. 4

    Choose how empty cells are written

    Keep an empty element or attribute, omit the field, or write an explicit marker. Empty text, a missing cell, and a marker are different conventions, so pick one that your reader understands.

  5. 5

    Generate and inspect the XML

    Review the sample document and mapping report, set the XML declaration and indentation, then run the full conversion. Check the result page before downloading or continuing.

Building an XML document from CSV rows

A CSV is a list of rows; an XML document is a tree of elements and attributes. Before you convert csv to xml, decide what the receiving system expects: a .xml extension alone does not make a document usable. A csv to xml converter has to build a structure, so this page keeps that structure explicit — one root element, one record element per CSV row, attributes on the record, and child elements beneath it. Converting csv to xml is a mapping task, not a rename.

How to convert CSV to XML

To convert csv file to xml, open a CSV file, paste records, or start with the example; check the delimiter, header row and encoding; set the root and record names; map each column to an element, an attribute or Exclude; choose an empty-value policy; then run the full conversion and inspect the result. If you convert csv file to xml online, check the privacy and processing notes on this page rather than assuming how the input is handled.

  1. Choose a source. Open a file, paste records, or start with the example. Confirm the delimiter, header row and encoding.
  2. Name the structure. Set the root and record element names; both must be valid XML names and must differ.
  3. Map the columns. Decide which columns become elements, which become attributes, and which are excluded.
  4. Choose empty values. Keep an empty element, omit the field, or write an explicit marker.
  5. Generate and inspect. Review the sample and mapping report, run the full conversion, then check the result before downloading.

What structure will the XML have?

One CSV data record becomes one record element inside a single root element. Attributes are convenient for identifiers and short metadata, while child elements are easier to extend later. Column order in the mapping controls element order. Two columns that would produce the same output name block generation until you resolve the conflict. This csv to xml conversion tool does not group rows by a repeated ID or invent a hierarchy from repeated values; an online csv to xml converter should show these choices before producing a file.

To convert a csv to xml for a specific importer, follow the structure that importer documents rather than choosing names only because they read well.

Can a CSV header become an XML element name?

Not always. XML names cannot start with a digit and cannot contain spaces or certain punctuation, so headers such as 2nd address or total (USD) need valid output names. The mapping panel suggests a name using the stable column ID and lets you edit it; nothing is renamed silently, and invalid names, duplicate names and a root that matches the record name are listed before generation.

Do values stay the same?

Cell values are written as text by default. Leading zeros, long identifiers, date-like strings, quotes, commas and line breaks inside cells are escaped by the serializer rather than reinterpreted as numbers or dates. For a csv file to xml mapping, that means 00123 stays 00123 and a quoted comma becomes ordinary element text.

What should an empty cell become?

An empty string, a missing cell and an explicit null marker may mean different things to the system that reads the file. XML has no universal null, so choose one of three visible policies: keep an empty element or attribute, omit the field, or write a marker you provide. The mapping report records the chosen policy. If you convert from csv to xml for an import, pick the convention the importer expects rather than assuming an empty element is treated as null.

Does the generated XML match my schema?

A document that opens in a browser is not necessarily the document your application needs. Check the root and record names, attribute placement, element order, escaped characters, empty-value handling and the record count in the mapping report. Generation is checked by a strict XML parser that rejects DTD and entity declarations; it does not validate against an XSD or a receiving system's schema. Can you convert csv to xml and assume schema compliance? No — that requires an explicit validation step against the required schema.

Before you download

The XML shown on the tool page is a labeled sample, not the complete file. Download and continuing use the same full result generated when you run the conversion, and a canceled or incomplete operation produces no final result. Set the XML declaration, indentation and encoding deliberately so the declaration matches the bytes you download. Once the mapping is checked you can convert csv to xml file and download it, or continue with a tool that accepts an XML artifact. If you convert csv to xml online as part of a repeated task, keep the same mapping snapshot so results stay comparable.

For the reverse direction, use XML to CSV, where you choose the record element again and inspect the resulting table. If your data starts in an Apple Numbers workbook, use Numbers to CSV first. You can also check a CSV source in CSV Viewer, browse the conversion tools, or review the current session in the workspace. Only tools that accept the selected artifact are offered as next steps.

Frequently Asked Questions

How do I convert CSV to XML?

Choose a CSV source, check the delimiter, header row and encoding, then set the root and record element names. Map each column to an element, an attribute or Exclude, choose an empty-value policy, run the full conversion and check the result before downloading.

Can CSV headers be used as XML element names?

Not always. XML names cannot start with a digit and cannot contain spaces or certain punctuation. The mapping panel suggests a valid output name from the stable column ID and shows invalid names so you can correct them yourself; nothing is renamed silently.

Can I group rows or build nested XML?

This page generates one record element per CSV row inside a single root element, with attributes on the record and elements beneath it. Grouping by a repeated ID, arbitrary hierarchy and schema-driven structures are not supported; that would require a separate, explicit rule.

Are empty CSV cells written as null?

No. XML has no universal null value. You choose whether an empty cell becomes an empty element or attribute, is omitted, or is written with an explicit marker. An empty string, a missing cell and a marker are distinct conventions, so pick the one the receiving system expects.

Does generation validate the XML against an XSD?

No. The generated document is checked by a strict XML parser that rejects DTD and entity declarations, and the mapping report lists the settings used. A document that parses is not proof of compliance with an XSD or a receiving application's schema.

Can I get my original XML file back from the CSV?

Only within the structure this page creates. A CSV table does not retain comments, processing instructions, mixed content, arbitrary nesting or document-level metadata. This is a new XML export built from CSV rows, not a lossless round trip.

Will leading zeros and long identifiers stay as text?

Yes, by default. Values are written as text and escaped by the serializer, so 00123 stays 00123, a quoted comma becomes ordinary element text, and date-like strings are not reinterpreted. The example above shows this with an identifier and a quoted field.

Does a successful preview mean the whole file was generated?

No. The XML shown on the tool page is a labeled sample. Download and continuing use the same full result produced when you run the conversion, and a canceled or incomplete operation produces no final result.

Where do I go for the reverse XML to CSV conversion?

Use XML to CSV, a separate task where you choose the record element and inspect the resulting table. This page only builds XML from CSV rows.