Transfonic Editorial TeamEditorial18 May 2026

How to Convert a Text File to CSV — Online, Excel, and Python Methods

How to Convert a Text File to CSV — Online, Excel, and Python Methods by Transfonic

Converting a text file to CSV is one of the most common data tasks there is — and also one of the most misunderstood. The actual file format difference between TXT and CSV is smaller than most people think. Both are plain text. Both store data as characters. The difference is structure: a CSV file uses commas to separate values into columns and line breaks to separate rows, following a defined pattern that every spreadsheet, database, and analytics tool understands natively.

A plain TXT file might have that same structure already — values separated by tabs, pipes, spaces, or commas — but saved with the wrong extension or without the standard delimiter that downstream tools expect. Converting it to CSV means reformatting the delimiter into standard comma separation and saving the result with a .csv extension so every tool opens it correctly.

This guide covers every method: a free online converter for quick single-file conversions, Microsoft Excel's built-in import wizard for structured workflows, and Python for batch or automated processing. It also covers the most common problems — encoding errors, misaligned columns, and delimiter confusion — and how to fix them.

What Is the Difference Between TXT and CSV?

A TXT file is a plain-text file with no defined structure. It can contain anything: prose, code, logs, data. A CSV file is also a plain-text file, but it follows a specific structure defined by RFC 4180 — each line is a data record, and each field within a record is separated by a comma. The .csv extension signals to applications that the file contains structured tabular data and should be opened as a spreadsheet rather than a document.

In practice, many TXT files already contain structured data — just with a different delimiter. Tab-separated files (TSV), pipe-separated files, space-delimited exports from legacy systems, and fixed-width report formats are all text files with structure. Converting them to CSV means either replacing the delimiter with a comma or reformatting the fixed-width layout into clean column-separated rows.

The reason this matters: Excel, Google Sheets, databases, CRMs, analytics tools, and data pipelines all expect CSV as their default import format. A .txt file opened in Excel may display everything in a single column, require manual splitting, or fail to import at all. The same data saved as .csv opens correctly, with columns aligned and data ready to use.

Method 1 — Convert TXT to CSV Online Free (Fastest)

The fastest method for occasional conversions is a browser-based tool. No software to install, no account required, no file size tricks.

How to convert TXT to CSV using Transfonic:

  1. Go to transfonic.com/document-conversion/csv-conversion

  2. Upload your TXT file by dragging it onto the converter or clicking to browse

  3. Select CSV as the output format

  4. Click Convert and download your CSV file

Your file is processed in your browser and deleted immediately after conversion. No account, no watermark, no data retained.

When to use this method: Single files, quick conversions, situations where you do not have Excel or Python available, or when working on a device where installing software is not an option. Works on Windows, macOS, Linux, iOS, and Android.

Limitation: Online converters work best with consistently delimited text files — tab-separated, comma-separated, or pipe-separated. Fixed-width text files with no clear delimiter character may need manual adjustment after conversion.

Method 2 — Convert TXT to CSV Using Microsoft Excel

Excel's built-in Text Import Wizard handles the most common TXT-to-CSV conversion scenarios without any additional software. This method gives you full control over delimiter detection, column formatting, and encoding — making it the best choice for structured workflows where you need to review the data before saving. Full documentation is available on the Microsoft Support page for importing and exporting text files

Steps to convert TXT to CSV in Excel:

  1. Open Excel and create a new blank workbook

  2. Go to Data → Get Data → From File → From Text/CSV

  3. Browse to your TXT file and click Import

  4. Excel opens a preview window and attempts to detect the delimiter automatically

  5. If the detection is wrong, open the Delimiter dropdown and select the correct one — Tab, Comma, Semicolon, Space, or Custom

  6. Review the column preview to confirm the data is splitting correctly

  7. Click Load to bring the data into the spreadsheet

  8. Go to File → Save As, choose a location, and select CSV (Comma delimited) (*.csv) from the Save as type dropdown

  9. Click Save — Excel will warn that CSV format does not support multiple sheets; click OK to continue

If your TXT file uses tabs as separators: Select Tab as the delimiter in step 5. Tab-separated files are technically TSV format. If you have a TSV file, Transfonic's tsv to csv converter handles this directly without needing to open Excel.

If your TXT file came from a database export or an older system: It may use a pipe character (|) or a semicolon (;) as the delimiter. In step 5, select Custom and type the character your file uses.

Encoding note: If your data contains special characters — accented letters, non-Latin scripts, currency symbols — set the encoding to UTF-8 in the preview window before loading. Failing to do this is the most common cause of garbled characters in the output CSV.

Method 3 — Convert TXT to CSV Using Python

Python is the right tool when you have multiple files to convert, the process needs to run automatically on a schedule, or the TXT files are too large or too numerous to handle manually. Python's built-in csv module handles everything without any external libraries.

Basic TXT to CSV conversion in Python:

import csv

input_file = 'data.txt'

output_file = 'data.csv'

delimiter = '\t'  # Change to '|' or ',' or ' ' to match your file

with open(input_file, 'r', encoding='utf-8') as txt_file:

    lines = txt_file.readlines()

with open(output_file, 'w', newline='', encoding='utf-8') as csv_file:

    writer = csv.writer(csv_file)

    for line in lines:

        row = line.strip().split(delimiter)

        writer.writerow(row)

print(f"Converted {input_file} to {output_file}")

Change the delimiter variable to match whatever your TXT file uses to separate values: '\t' for tab, '|' for pipe, ',' for comma, ' ' for space.

Batch conversion — converting an entire folder of TXT files:

import csv

import os

input_folder = 'txt_files'

output_folder = 'csv_files'

delimiter = '\t'

os.makedirs(output_folder, exist_ok=True)

for filename in os.listdir(input_folder):

    if filename.endswith('.txt'):

        input_path = os.path.join(input_folder, filename)

        output_path = os.path.join(output_folder, filename.replace('.txt', '.csv'))

        with open(input_path, 'r', encoding='utf-8') as txt_file:

            lines = txt_file.readlines()

        with open(output_path, 'w', newline='', encoding='utf-8') as csv_file:

            writer = csv.writer(csv_file)

            for line in lines:

                row = line.strip().split(delimiter)

                writer.writerow(row)

        print(f"Converted: {filename}")

print("All files converted.")

Place all your TXT files in a folder named txt_files, run the script, and find the converted CSVs in csv_files. Adjust the delimiter to match your source files.

When to use Python: Any situation involving more than a handful of files, automated pipelines, scheduled exports from systems that produce TXT output, or integration with other data processing steps. Python's csv module also handles edge cases that online tools and Excel may miss — quoted fields containing commas, embedded newlines, and non-standard encodings.

Method 4 — Convert ODS to CSV

ODS (OpenDocument Spreadsheet) is the default format for LibreOffice Calc and other open-source spreadsheet applications. If your data is in an ODS file and you need it as CSV — for database import, data pipeline input, or sharing with a tool that does not support ODS — you can convert it directly without opening LibreOffice.

Transfonic's ods to csv converter handles ODS to CSV in the same three-step workflow: upload, select CSV output, download. No LibreOffice installation required. Files are deleted immediately after conversion.

Method 5 — Convert XLSX to CSV

If your data is in an Excel spreadsheet and you need it as CSV, the xlsx to csv converter is the fastest method. Upload your XLSX file, select CSV as the output, and download a clean comma-separated file ready to import into any tool. This is also covered in depth in the complete guide to how to convert xlsx to csv, which covers every method and every common problem including multi-sheet workbooks, encoding issues, and formula preservation.

Common Problems and How to Fix Them

Problem: Everything appears in a single column when I open the CSV in Excel

This happens when Excel does not detect the delimiter correctly, or when the CSV uses a semicolon instead of a comma (common in European locale settings). Fix: In Excel, go to Data → Text to Columns, select Delimited, choose Comma, and click Finish. This splits the single column into properly separated columns.

Problem: Special characters display as garbled symbols (Ãé, �)

This is an encoding mismatch. Your TXT file is encoded in UTF-8 but Excel is reading it as a different encoding (typically Windows-1252 or Latin-1). Fix in Excel: When using the Text Import Wizard, set File Origin to 65001: Unicode (UTF-8) before importing. Fix in Python: Always specify encoding='utf-8' in both the read and write operations.

Problem: My TXT file has inconsistent spacing instead of a clear delimiter

Fixed-width text files — common exports from mainframes, legacy accounting systems, and scientific instruments — use spaces to pad fields to a fixed character width rather than using a delimiter character. These require a different approach: you need to specify the exact character positions for each column. In Excel, use the Text Import Wizard and select Fixed Width instead of Delimited, then drag the column markers to the correct positions. In Python, use string slicing to extract each field by its character position.

Problem: My CSV has the wrong number of columns on some rows

This usually means some values in your TXT file contain the delimiter character (a comma inside a field that uses commas as separators). The correct fix is to ensure those fields are enclosed in double quotes in the output. Python's csv module handles this automatically — it will quote any field that contains a comma. Online tools and Excel may handle it inconsistently; if column counts are wrong after conversion, Python is the most reliable method.

Which Method Is Right for You?

Situation

Best Method

One TXT file, quick result, no software

Online converter — csv conversion

Need to review and adjust columns before saving

Excel Text Import Wizard

Many files, batch processing, automated workflow

Python

Tab-separated TSV file

Tsv to csv

ODS spreadsheet file

Ods to csv

Excel XLSX spre Microsoft Support page for importing and exporting text files. adsheet

Xlsx to csv

FAQs

What is the fastest way to convert a TXT file to CSV?

"

The fastest method is a browser-based online converter. Upload your TXT file to transfonic.com/document-conversion/csv-conversion, select CSV as the output format, and download the result in seconds. No account, no software installation, no file retained after conversion.

Can I convert a TXT file to CSV without Excel?

"

Yes. Transfonic's online converter processes TXT to CSV entirely in your browser with no Excel or Microsoft Office required. Python's built-in csv module also handles TXT to CSV conversion without any office software installed.

What delimiter should I use when converting TXT to CSV?

"

It depends on what your TXT file uses to separate values. Tab-separated files use a tab character (\t). Pipe-separated files use |. Some European exports use semicolons. If you are unsure, open the TXT file in a text editor and look at what character appears between values on any given row. When converting to CSV, all delimiters get standardized to commas.

Why does my CSV look wrong after converting from TXT?

"

The most common causes are: wrong delimiter detected during conversion, encoding mismatch causing special characters to display incorrectly, or fixed-width formatting that was not parsed into proper column boundaries. The troubleshooting section above covers each of these with specific fixes.

How do I convert a tab-delimited TXT file to CSV?

"

A tab-delimited file is technically a TSV (Tab-Separated Values) file. The fastest method is Transfonic's transfonic.com/document-conversion/tsv-to-csv converter, which handles the tab-to-comma delimiter change automatically. In Excel, use Data → Get Data → From Text/CSV, set the delimiter to Tab, load the data, then Save As CSV.

Productivity Picks _ How to Convert a Text File to CSV — Online, Excel, and Python Methods

Relevant Article _ How to Convert a Text File to CSV — Online, Excel, and Python Methods

01

JSON to CSV: Online Tools, Python Scripts and Excel Methods Explained

Every developer who has pulled data from an API knows the moment: you have a clean JSON response, but your client, manager, or data team needs it in a spreadsheet — now. The question is not whether JSON to CSV conversion is possible. It is the method that is fastest, most reliable, and right for your specific situation.

02

How to Convert Excel to CSV (And CSV Back to Excel) — Complete 2026 Guide

Converting an Excel spreadsheet to CSV — or bringing a CSV file back into Excel — is one of the most common data tasks people run into. Whether you need to import data into a database, feed a file into an analytics tool, or share clean data with a developer, this guide covers every method, every problem, and every question you will run into.

03

How to Convert PNG to JPG (and JPG to PNG) on Mac, Windows, iPhone & Online

If you've ever tried to upload an image and been told the file is "too large" or "wrong format," you already know why converting between PNG and JPG matters. These are the two most common image formats on the planet, and switching between them is one of those small tasks that should be simple — but most guides bury the answer under software ads and confusing jargon. This guide fixes that. You'll learn how to convert PNG to JPG and JPG to PNG using the free tools already built into your Mac and Windows PC, how to do it on your phone, and the fastest way to convert one image or hundreds at once in your browser. We'll also clear up the single biggest myth about this conversion — the one almost every tutorial gets wrong. If you just want it done right now, you can convert PNG to JPG online or use the JPG to PNG converter — both run in your browser, free, with no signup and no files ever uploaded to a server. Otherwise, read on for every method.

04

How Online File Content Conversion Tools Save You Hours Each Week

In today’s fast-paced digital world, managing multiple file types—documents, images, and audio—can be overwhelming. From PDFs to Word files, scanned images to audio files, manually converting and extracting content can consume hours of your week, slowing down productivity and increasing the chance of errors.

Top Picks _ How to Convert a Text File to CSV — Online, Excel, and Python Methods

Random Text Generator

A random text generator helps you create varied placeholder ...

WAV to Text

Transcribe WAV audio files to text effortlessly. Our online ...

FLAC to Text

Convert FLAC audio recordings into editable text quickly and...

AAC to Text

Easily transcribe AAC audio files into text. Our online tool...

M4A to Text

Quickly transcribe M4A audio files to text with our fast and...

AIFF to Text

Transform AIFF audio files into text quickly and accurately ...

ALAC to Text

Convert ALAC audio files into editable text effortlessly wit...

Image PDF to Text

Use image pdf to text to convert image-based PDF pages into ...

WMA to Text

Easily convert WMA audio recordings into editable text with ...

Text To Ascii

Convert regular text to ascii for creative and stylized outp...

CSV to XLSX

Convert CSV files into XLSX spreadsheets instantly with Tran...

CSV to PDF

Convert CSV files into high-quality PDF documents online wit...

CSV to TXT

Convert CSV files into plain TXT format online with Transfon...

ODS to CSV

Convert ODS files into CSV format online with Transfonic. Pe...

Scanned PDF to Text

Use Scanned PDF to text to quickly extract readable, editabl...

PDF to Editable Text

Use pdf to editable text to turn PDF content into text you c...

MP3 to Text

Convert your MP3 audio files into editable text quickly and ...

OGG to Text

Convert OGG audio files into editable text effortlessly. Our...

Dummy Text Generator

A dummy text generator makes it easy to produce simple place...

Placeholder Text Generator

A placeholder text generator lets you create natural-looking...