Format Code Now
/
ConvertXML to TSV Converter Next: JSON to Dart ›

XML to TSV Converter

CV-72

Paste XML with repeated records and get tab-separated rows. Attributes and child elements become columns, and the result pastes straight into a spreadsheet.

Runs in your browser. Nothing is uploaded.

XML

TSV

How to use it

  1. Paste your XML into the input box, or open a .xml file and drop it on the box.
  2. Leave Write a header row on, or turn it off for data rows only.
  3. Check the columns in the first row.
  4. Copy the TSV or download it as a .tsv file.

How records and columns are found

The tool looks for the first element that has repeated children, such as many book elements under a catalog, and writes one row for each. If nothing repeats, the whole document becomes a single row. Columns are built from what the records contain: an attribute is written as @id, a child element uses its name, a nested element is written as author.name, and a name that repeats inside one record becomes tag[0], tag[1]. The column list is the union of all records, in order of first appearance.

Values and quoting

Values are trimmed text, and a record that has both text and attributes puts its text in a #text column. A record that is missing a column gets an empty cell. A value that holds a tab or a line break, or starts with a double quote, is wrapped in double quotes with inner quotes doubled, which Excel and Google Sheets read correctly. Nothing is converted to numbers or dates.

What is ignored

Comments and processing instructions are ignored. The XML must be well formed, and the first problem is reported with its line and column. Only the five built-in entities and numeric references are decoded, so custom DTD entities are an error. For a layout that differs from this one, for example when records are nested at several levels, convert to JSON first to inspect the structure.

Error messages and what to do

MessageWhat it meansFix
Expected </b> (opened on line 1) but found </a> at line 1, column 8A closing tag does not match the element that is open.Close the tags in the reverse order that they were opened.

Questions people ask

How do I convert XML to TSV?

Paste the XML and the TSV appears. The repeated elements become rows and their attributes and children become columns. Copy it and paste it into a spreadsheet.

Which element becomes the row?

The first element, searching from the top down, that has repeated children. In a catalog of books, that is each book. If nothing repeats, the whole document becomes one row.

How are attributes written?

With an at sign in front, such as @id, so they stay apart from child elements that have the same name. Nested child elements use a dot, as in author.name.

What if records have different fields?

The columns are the union of all fields in order of first appearance, and a record without a field gets an empty cell. Nothing is dropped.

Can I leave out the header row?

Yes. Turn off Write a header row to get the data rows only, for example to append to an existing sheet. The result updates as soon as you change the input or an option.

About this tool

The tool looks for the first element that has repeated children, such as the book elements above, and writes one row for each. If nothing repeats, the whole document becomes a single row. Columns are built from what the records contain: an attribute is @id, a child element is its name, a nested element is written as author.name, and a name that repeats inside one record is written as tag[0], tag[1]. The column list is the union across all records in order of first appearance, and a record without a column gets an empty cell. Values are trimmed text; a record with its own text and attributes uses #text. A value that holds a tab or line break, or starts with a double quote, is wrapped in quotes with inner quotes doubled. Comments and processing instructions are ignored, and the XML must be well formed.

Format Code Now: free, no ads, no accounts. Your input stays in your browser.