How to convert TXT to XML
- Drop your TXT file on the box above, or paste its content into the text box.
- Check the settings below the box; the defaults suit most files.
- Press Convert. You see a preview or a summary of the result.
- Download the .xml file, or copy the text.
What is kept when you convert TXT to XML
- Each line (or each paragraph) becomes a numbered element, in order, with &, <, > and quotes escaped.
- The file is UTF-8 and declares it, so any script survives.
- Control characters that XML 1.0 forbids (such as NUL or form feed) are removed — the tool tells you how many, because they cannot be stored in XML at all.
Example
A short TXT input and the exact output this tool produces from it:
Input
Shopping list
Milk, 2 litres
Bread & butter
"Fresh" eggs <12> Output
<?xml version="1.0" encoding="UTF-8"?>
<document>
<line n="1">Shopping list</line>
<line n="2"/>
<line n="3">Milk, 2 litres</line>
<line n="4">Bread & butter</line>
<line n="5">"Fresh" eggs <12></line>
</document>
About TXT and XML files
A .txt file is plain text: characters and line breaks, with no fonts, sizes or layout. It is what Notepad, TextEdit, code editors and many export buttons produce. It opens in any text editor.
XML stores data as nested, named elements. Element names must follow XML’s rules, special characters are escaped, and a few control characters are not allowed at all. It opens in code editors, Excel (as an XML table), databases, integration tools.
Good to know
- If accented letters show up as é or ?, the text file was saved in an older Windows encoding; this tool reads UTF-8 and falls back to Windows-1252 automatically, so open the result and check one accented word.
- If the target system has its own XML schema, rename the root and record elements to match it in the settings.
Privacy and limits
The file is read and converted by this page in your browser; there is no upload and no account. Files up to 25 MB are accepted; a file of the wrong type or a damaged file is rejected with the reason.