Format Code Now
/
ConvertTSV to XML Next: XML to CSV ›

TSV to XML Converter

CV-111

Paste tab-separated values and get XML: a root element, one element per row, and a child element for each column named after the header.

Runs in your browser. Nothing is uploaded.

TSV (optional first lines: -- root: name, -- row: name)

XML

How to use it

  1. Paste your TSV.
  2. Pick the root and row element names, or add -- root: and -- row: lines at the top.
  3. Choose the indent and the XML declaration.
  4. Press TSV to XML, then copy or download.

Mapping columns to elements

The header row supplies the element names. Names XML does not allow have the bad characters replaced with an underscore, a name that starts with a digit gets a leading underscore, and duplicates get _2 and _3. Without a header row the columns are named column_1, column_2 and so on. Empty cells become empty elements, short rows are padded, and all values are text. A field in double quotes is read as CSV is, so it can contain a line break.

Choosing names and what is not written

The lists cover common root and row names. For others, put -- root: orders and -- row: order on the first lines of the input; they are read and removed before conversion. Text is escaped, and control characters that XML 1.0 cannot hold are an error. The tool writes elements only, never attributes, and it does not add a schema or namespace.

Error messages and what to do

MessageWhat it meansFix
No rows found in the CSV.The input has no data rows.Paste a header line and at least one row.

Questions people ask

How do I convert TSV to XML?

Paste the TSV and press TSV to XML. The first line gives the element names and each following line becomes a row element. Copy the XML or download the .xml file.

Can I name the root element?

Yes. Pick one from the list, or put a first line such as -- root: orders in the input. The same works for the row element with -- row: order.

What happens to header names with spaces?

XML names cannot contain spaces, so "first name" becomes first_name. A header that starts with a digit gets a leading underscore, and repeated headers get _2, _3 and so on.

Does it write attributes?

No. Every column becomes a child element and nothing is written as an attribute. If you need attributes, build JSON with keys that start with @ and convert that with the JSON to XML tool on this site instead.

Are numbers typed in the XML?

No. XML text has no types, so every value is written as text exactly as it appears in the TSV. A value such as 007 keeps its zeros, and a number is never rounded.

About this tool

Each line becomes a row element and each tab-separated column becomes a child element named after the header. Header names that are not valid XML names have invalid characters replaced with _ (a leading digit gets a leading _), and duplicates get _2, _3. Without a header row the columns are named column_1, column_2 and so on. Empty cells become empty elements, text is escaped, and every value is text with no types. A field in double quotes is read as CSV is, so it can hold a line break. To choose the element names, put -- root: orders and -- row: order on the first lines. Control characters that XML 1.0 cannot hold are an error. It writes elements only, no attributes.

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