TXT files are everywhere in business. Legacy ERP exports, inventory dumps from older warehouse systems, healthcare records, government open data, developer logs, support reports. They are lightweight, universally readable, and easy to generate from any system that can write a file.
They are also awkward to work with. A raw text file cannot be sorted, filtered, or visualized. Converting it to Excel is usually the first step before anything useful happens with the data inside.
This guide covers the four methods to convert TXT to Excel, when each one is the right choice, and how to handle the three common flavors of TXT file you will encounter.
Before you start, identify the structure
Text files come in three forms, and the right import method depends on which one you have.
Delimited files use a specific character to separate values. Commas, tabs, pipes, and semicolons are the most common. These behave like CSVs with a different extension, and Excel handles them well once you tell it the right delimiter.
Fixed-width files give each field a specific character width, with padding to fill the gap. These were standard in mainframe and early ERP systems and are still produced by a lot of legacy software. Instead of a delimiter between fields, the file relies on column positions, for example characters 1 through 10 are the account number, 11 through 30 are the name, and so on.
Freeform text has no consistent structure. These files need to be cleaned before any import, usually in a text editor or with a script.
Open your file in Notepad or VS Code first to see which one you are dealing with. If values line up in clean vertical columns with lots of spaces between them, you likely have a fixed-width file. If you see tabs or pipes, it is delimited. If it looks like a wall of text with no obvious structure, it is freeform.
Method 1: Open the file directly in Excel
Excel has a Text Import Wizard that activates when you open a .txt file through File > Open. It is the default method and it handles both delimited and fixed-width files.
The wizard asks three questions. First, whether the file is delimited or fixed-width. Second, which delimiter or column widths to use, with a preview that shows the result. Third, what data type each column should have.
The data type step matters. Excel defaults to "General", which triggers the same auto-formatting traps as with CSV, leading zeros disappear in account numbers and phone numbers, dates get reinterpreted. Set columns containing IDs or codes to "Text" explicitly.
This method is the right choice for one-off conversions of small to medium files.
Method 2: Use the Import feature for more control
The path Data > Get Data > From File > From Text/CSV opens a modern preview dialog with better handling of encoding and more transformation options than the classic wizard. It is the right default for recent Excel versions.
The main advantage over method 1 is encoding detection. If the file uses a non-UTF-8 encoding (which is common with legacy exports), this dialog detects it or lets you override it cleanly. Files from older European systems often use Windows-1252, which breaks accented characters when opened with the default UTF-8 assumption.
Use this method whenever you suspect encoding issues, or when you need the preview to verify the import before it happens.
Method 3: Convert to CSV first in a text editor
If your TXT is consistently delimited but Excel is not recognizing it correctly, a manual conversion in Notepad often solves the problem faster than fighting with the import wizard.
Open the file in Notepad or VS Code. Use Find and Replace (Ctrl+H) to replace tabs or pipes with commas. Save the file with a .csv extension. Open in Excel.
This sounds primitive and it is, but it works reliably when the structure is clean and the alternatives are not cooperating. Useful when a system only exports TXT but you need the file as CSV anyway for another downstream tool.
Method 4: Automate with Python for recurring imports
If you convert the same TXT file shape every week from the same source, scripting is faster than doing it by hand. A few lines of Python using pandas handle the conversion reliably.
import pandas as pd
# For tab-delimited files
df = pd.read_table('your_file.txt')
# For fixed-width files, specify column widths
# df = pd.read_fwf('your_file.txt', widths=[10, 20, 8, 12])
df.to_excel('output.xlsx', index=False)
One-time setup is pip install pandas openpyxl. After that,
each conversion is one command. For weekly or monthly
reports, this saves hours over the course of a year.
Common problems and how to fix them
| Problem | Cause | Fix |
|---|---|---|
| Fields misaligned | Wrong delimiter selected | Re-import, choose the correct delimiter (tab, pipe, space) |
| All data on one line | File uses unusual line endings | Open in VS Code, change line endings to CRLF, re-save |
| Accented characters look broken | Non-UTF-8 encoding | Re-import with Windows-1252 or the correct encoding |
| Fixed-width columns split wrong | Wrong column widths specified | Count the characters in the file manually, set precise widths |
| Leading zeros disappear | Excel treats the column as Number | Set the column type to Text during import |
When TXT files should not be the interface
If you find yourself receiving the same kind of TXT file every week from the same system, and you spend time cleaning it up before loading it into Excel or your own product, you are treating the file as an integration point that it was never designed to be.
TXT exports from legacy systems are typically the thing the old system could produce, not the thing you actually need. They are manageable at low volume and painful at scale, especially when the format varies subtly from one export to the next.
For recurring TXT processing at scale, the right fix is usually upstream, a proper integration with the source system that avoids the file entirely, or a tool that absorbs the format variation automatically so you stop cleaning each file by hand. Excel is a great destination. It is not a great integration layer.
Conclusion
TXT to Excel is usually a two-step problem. Identify the structure, then pick the method that matches, direct open for small files, Import feature when encoding matters, text editor cleanup for stubborn files, Python for automation. The tools are all there. The trick is knowing which one fits the file on your desk today.
