How to Convert a TXT File to XLS: Methods, Tools, and What to Know First
Plain text files are everywhere — exported from databases, downloaded from apps, generated by scripts. But when you need to analyze, sort, or share that data, a .txt file rarely cuts it. Excel's .xls (or .xlsx) format gives you structure, formulas, and formatting that a plain text file simply can't provide.
Converting between these formats is straightforward once you understand what's actually happening — and which method fits your situation.
What's the Difference Between TXT and XLS?
A TXT file stores raw, unformatted text. Data inside it is usually separated by a consistent character — a comma, tab, pipe (|), or space — to indicate where one value ends and another begins. There's no built-in concept of rows, columns, or data types.
An XLS or XLSX file is a structured spreadsheet format developed by Microsoft. It organizes data into cells, rows, and columns, and supports formulas, data types (dates, currency, integers), conditional formatting, and more.
The conversion process is essentially parsing — reading the separator pattern in your text file and mapping each value into the correct spreadsheet cell.
How Delimiters Determine the Conversion 📄
Before converting, you need to know how your TXT file is structured. The most common formats:
| Delimiter Type | Example | Also Known As |
|---|---|---|
| Comma | John,Smith,42 | CSV (Comma-Separated Values) |
| Tab | John⇥Smith⇥42 | TSV (Tab-Separated Values) |
| Pipe | John|Smith|42 | Pipe-delimited |
| Space | John Smith 42 | Space-delimited |
| Fixed-width | John Smith 42 | Fixed-width format |
Getting the delimiter wrong during import results in all your data landing in a single column instead of spreading across many — one of the most common conversion mistakes.
Method 1: Open Directly in Microsoft Excel
Excel has a built-in Text Import Wizard that handles most TXT files without third-party tools.
Steps:
- Open Excel and go to File > Open
- Change the file filter to All Files and select your
.txtfile - The Text Import Wizard launches automatically
- Choose Delimited or Fixed Width depending on your file
- Select your delimiter (comma, tab, etc.)
- Preview the column structure, adjust data types if needed
- Click Finish, then Save As → choose Excel Workbook (.xlsx)
The wizard lets you set data types per column — important if you have fields like ZIP codes or phone numbers that Excel might otherwise reformat as integers.
In newer versions of Excel (Microsoft 365 and Excel 2016+), you can also use Data > Get & Transform Data > From Text/CSV, which provides a more modern import experience with better handling of encoding and data previews.
Method 2: Use Google Sheets (Free, Browser-Based) 🌐
If you don't have Microsoft Office, Google Sheets handles TXT-to-spreadsheet conversion reliably.
Steps:
- Go to sheets.google.com and create a new spreadsheet
- Go to File > Import
- Upload your TXT file
- Choose your separator type (or let Sheets detect it automatically)
- Confirm the import
- Download as Microsoft Excel (.xlsx) via File > Download
Google Sheets is particularly useful when working on Chromebooks, shared devices, or when you want a quick one-off conversion without installing software.
Method 3: LibreOffice Calc
LibreOffice Calc is a free, open-source alternative to Excel that handles TXT imports with a similar wizard to Microsoft's. It supports saving directly to .xls or .xlsx format.
This is a strong option for users who regularly work with large files, unusual encodings (UTF-8, UTF-16, Latin-1), or fixed-width formats — LibreOffice's import wizard gives fine-grained control over character encoding, which matters when working with international data sets.
Method 4: Command-Line and Scripted Conversion
For developers, data analysts, or anyone dealing with bulk files, scripted conversion is more efficient than opening files one by one.
Python with the pandas library is the most common approach:
import pandas as pd df = pd.read_csv('yourfile.txt', delimiter=' ') # adjust delimiter df.to_excel('output.xlsx', index=False) This method handles thousands of files in a loop, supports complex delimiter logic, and allows data cleaning during the conversion — renaming columns, dropping blanks, reformatting dates — all before writing the final Excel file.
PowerShell (Windows) can also handle basic conversions, though it's more limited for complex formatting requirements.
Variables That Affect Your Conversion
Not all TXT-to-XLS conversions are equal. Several factors determine how smooth or complicated yours will be:
- Encoding: If your file uses non-standard encoding (common with exported data from older systems), characters may appear garbled unless you specify the correct encoding during import
- File size: Very large TXT files (hundreds of thousands of rows) may strain Excel's row limit (1,048,576 rows in
.xlsx) or slow down browser-based tools - Data consistency: Inconsistent delimiters, quoted fields containing commas, or missing values add complexity that manual import wizards sometimes mishandle
- Data types: Dates, phone numbers, and leading zeros require careful handling — Excel's auto-formatting can silently corrupt these during import
- Column count: Files with many columns benefit from Python or LibreOffice, which give more control over column mapping
Fixed-Width Files: A Special Case
Fixed-width TXT files don't use a delimiter at all. Instead, each field occupies a set number of characters. These are common in legacy system exports, banking data, and government data sets.
Excel's Text Import Wizard handles fixed-width files, but you must manually drag column break markers to the correct positions. Python's pandas library handles this with pd.read_fwf(). Getting the column widths wrong by even one character misaligns everything downstream.
Choosing the Right Approach
The best method depends on factors specific to your situation: how often you're doing this, whether it's a one-time task or part of a workflow, how clean and consistent your source file is, what software you already have installed, and whether you need to transform the data during conversion or just move it as-is.
A simple tab-delimited file opened in Excel once a month is a very different scenario from a daily automated export of pipe-delimited records with encoding edge cases — even if both are described as "converting TXT to XLS."