Xerobit

CSV to XML Converter

Paste your comma-separated values to convert CSV to XML instantly. The parser handles quoted fields, embedded commas, doubled quotes and newlines according to RFC 4180. Choose your delimiter, toggle the header row and get clean XML output. Everything runs in your browser so no data is uploaded.

XML Output

<?xml version="1.0" encoding="UTF-8"?>
<records>
  <row>
    <name>Alice</name>
    <age>30</age>
    <city>New York</city>
  </row>
  <row>
    <name>Bob</name>
    <age>25</age>
    <city>London</city>
  </row>
</records>

How to use the csv to xml converter

  1. Paste your CSV data into the CSV input text area.
  2. Select the correct Delimiter if your data uses semicolons, tabs or pipes instead of commas.
  3. Check First row is header if your first line contains column names; uncheck it to use generic field tags.
  4. The XML Output updates automatically as you type.

How the CSV to XML conversion works

The converter reads your input character by character following RFC 4180 rules. When it encounters a double quote at the start of a field, it treats everything until the closing quote as literal text, including commas and newlines. Two consecutive double quotes inside a quoted field are collapsed into a single quote character.

For example, given this input:

name,note
Alice,"She said ""hi"""

The parser produces two columns and one data row. The second field resolves to She said "hi". With the header option enabled, the resulting XML element becomes:

<row>
  <name>Alice</name>
  <note>She said &quot;hi&quot;</note>
</row>

Special XML characters like ampersands, angle brackets and quotes inside cell values are escaped automatically so the output remains well-formed.

Header rows and tag naming

When First row is header is checked, the converter uses each value in the first row as the XML tag name for that column. Tag names must follow XML rules: they cannot start with a digit, and they cannot contain spaces or most punctuation. The tool sanitizes headers automatically by replacing invalid characters with underscores and prepending an underscore if a header starts with a number.

If you uncheck the header option, the converter assigns generic tags: field1, field2, field3 and so on. This is useful when your CSV has no header row and you just need structured XML output.

Duplicate headers are also handled. If two columns share the same name, the second occurrence gets a numeric suffix to keep every tag unique within its parent row element.

Handling ragged rows

Real-world CSV files often have inconsistent column counts. A file might have five columns in the header but only three values in a later row, or extra trailing commas that produce empty fields. Rather than silently discarding data or crashing, this csv to xml converter reports ragged rows honestly.

If a data row has fewer fields than the header, the missing elements are still emitted as empty tags so the XML schema stays consistent across all rows. If a data row has more fields than expected, the extra values are wrapped in additional numbered tags and a warning comment is added right after the XML declaration (and repeated in a note under the result) listing which rows were ragged.

This approach means you always get valid XML while staying informed about irregularities in your source data.

Delimiters beyond commas

Although CSV stands for comma-separated values, many systems export data using semicolons, tabs or pipe characters. European spreadsheet applications frequently default to semicolons because the comma serves as the decimal separator in those locales.

Use the Delimiter dropdown to match your source format. The parser applies the same RFC 4180 quoting rules regardless of which delimiter you choose. Quoted fields can still contain the delimiter character without breaking the parse.

If you need to change delimiters before converting, you can first run your data through a CSV delimiter converter to standardize it.

Common CSV edge cases

Several patterns trip up naive parsers. Here is how this tool handles them:

  • Embedded newlines: A field wrapped in double quotes can contain literal line breaks. The parser keeps reading until it finds the closing quote, preserving the newline inside the XML element.
  • Doubled quotes: Inside a quoted field, two consecutive double quotes represent a single literal quote character. Unquoted fields do not use this escaping.
  • CRLF vs LF: Both Windows-style carriage-return plus line-feed and Unix-style line-feed are recognized as row terminators outside of quoted fields.
  • Trailing newlines: An empty final line caused by a trailing newline is ignored rather than producing an empty row element.
  • Empty fields: Two adjacent delimiters produce an empty string, rendered as a self-closing or empty XML tag.

Worked examples

ExampleInputResult
Simple table with headersCSV input: name,age,city / Alice,30,New York / Bob,25,London; Delimiter: ,; First row is header: yes<?xml version="1.0" encoding="UTF-8"?> / <records> / <row> / <name>Alice</name> / <age>30</age> / <city>New York</city> / </row> / <row> / <name>Bob</name> / <age>25</age> / <city>London</city> / </row> / </records>
Quoted fields with commasCSV input: "Last, First",Role / "Doe, John","Manager, Sales"; Delimiter: ,; First row is header: yes<?xml version="1.0" encoding="UTF-8"?> / <records> / <row> / <Last_First>Doe, John</Last_First> / <Role>Manager, Sales</Role> / </row> / </records>
No header rowCSV input: Alice,30 / Bob,25; Delimiter: ,; First row is header: no<?xml version="1.0" encoding="UTF-8"?> / <records> / <row> / <field1>Alice</field1> / <field2>30</field2> / </row> / <row> / <field1>Bob</field1> / <field2>25</field2> / </row> / </records>
Semicolon delimitedCSV input: id;value / 1;100 / 2;200; Delimiter: ;; First row is header: yes<?xml version="1.0" encoding="UTF-8"?> / <records> / <row> / <id>1</id> / <value>100</value> / </row> / <row> / <id>2</id> / <value>200</value> / </row> / </records>

FAQ

Does this csv to xml converter upload my data?

No. The entire conversion happens locally in your browser using JavaScript. Your CSV data never leaves your device and is never sent to any server.

Can I use a semicolon or tab as the delimiter?

Yes. Select Semicolon, Tab or Pipe from the Delimiter dropdown. The parser applies the same RFC 4180 quoting rules regardless of which character you choose.

What happens if my CSV rows have different numbers of columns?

The converter reports ragged rows in a comment above the XML output. Missing fields become empty tags, and extra fields receive numbered tags so the XML remains well-formed.

Are special characters in cell values escaped?

Yes. Ampersands, angle brackets and double quotes inside cell values are replaced with their XML entity equivalents so the output is always valid XML.

What if my CSV has no header row?

Uncheck the First row is header option. The converter will use generic tag names like field1, field2 and field3 for each column.

Does it handle fields that contain line breaks?

Yes. As long as the field is enclosed in double quotes per RFC 4180, embedded newlines are preserved inside the corresponding XML element.

Can I convert very large CSV files?

The tool processes data in memory, so performance depends on your device. It handles typical spreadsheets comfortably, but extremely large files may cause the browser tab to slow down.