Skip to content
New: 17 free file converters that never upload your files
File Converter Guides

How to Convert TXT to CSV: Excel, Google Sheets, Python and a Free Browser Tool

Learn how to convert TXT to CSV with a free browser tool, Excel, Google Sheets, Notepad, Python or PowerShell, without losing leading zeros or columns.

How to convert TXT to CSV: LeadCanal guide cover
On this page
  1. What is the difference between a TXT file and a CSV file?
  2. How to convert TXT to CSV with our free browser tool
  3. How do you convert a text file to CSV in Excel?
  4. How to convert TXT to CSV in Google Sheets
  5. Can you convert TXT to CSV in Notepad by renaming the file?
  6. How do you convert TXT to CSV in LibreOffice Calc?
  7. How to convert a TXT file to CSV with Python
  8. How to convert TXT to CSV from the command line
  9. Which method should you use? A comparison
  10. What limits should you know before converting large files?
  11. Troubleshooting: why does my converted CSV look wrong?
  12. What can you do with the CSV once it is converted?
  13. Frequently asked questions
  14. Conclusion: key takeaways
  15. Editorial policy
  16. Content transparency
  17. About the author

If you are wondering how to convert TXT to CSV, the short answer is this: work out which character separates the columns in your text file (usually a tab, pipe, semicolon or fixed-width spacing), then let a tool rewrite those separators as commas while keeping quotes, encoding and leading zeros intact. The fastest no-install option is our free TXT to CSV converter, which runs in your browser. Excel, Google Sheets, Python and PowerShell all do the job too, and we cover each one below.

We convert text exports from old CRMs and email tools every week while cleaning client lead lists, so this guide also covers the mistakes that quietly break files.

Quick answer: To turn a .txt file into a .csv file without losing data:

  • Fastest: drop the file into the free convert TXT to CSV tool, confirm the delimiter, check the preview and download the CSV. Nothing is uploaded.
  • Excel: Data > From Text/CSV, pick the delimiter, load it, then File > Save As > CSV UTF-8 (Comma delimited).
  • Google Sheets: File > Import > Upload, choose the separator, then File > Download > Comma-separated values (.csv).
  • Python: read with csv.reader(f, delimiter="\t") and write with csv.writer.
  • Only rename .txt to .csv if the file is already comma-separated.

Free LeadCanal tools for this guide

Check and fix it yourself in a few seconds, no signup needed.

TXT to CSV →CSV Splitter →TXT to JSON →CSV to VCF →

What is the difference between a TXT file and a CSV file?

Both are plain text. A CSV file is simply a text file that follows a convention: one record per line, fields separated by commas, and fields that contain commas, quotes or line breaks wrapped in double quotes. The common rules are written up in RFC 4180.

A .txt file has no rules at all. It might be a tidy table separated by tabs, a report padded with spaces, or a loose list of names and emails. That is why converting one is really a question of identifying the delimiter correctly. Get that right and every method below works.

Which delimiter does your text file use?

Open the file in Notepad, TextEdit or any code editor and look at the first two or three lines.

Format What it looks like Where it usually comes from Setting to choose
Tab-delimited Columns line up loosely with wide gaps Excel “Text (Tab delimited)”, CRM and database exports Tab, \t
Pipe-delimited Jane|Smith|Acme Ltd Banking, ERP and legacy system exports Custom: |
Semicolon-delimited Jane;Smith;Acme Ltd European locale exports where the comma is the decimal mark Semicolon
Fixed width Every column starts at the same character position, padded with spaces Mainframe, payroll and government data files Fixed width with column breaks
Already comma-separated Jane,Smith,Acme Ltd Files saved with the wrong extension Just rename it
Unstructured Paragraphs, notes or email bodies Copied web pages, inbox exports Extract the data first

Tabs are hard to see: if the cursor “jumps” across a gap with one arrow key press, it is a tab.

How to convert TXT to CSV with our free browser tool

We built the LeadCanal TXT to CSV converter because we kept writing one-off scripts for client files.

  1. Open the converter and drop in your .txt file.
  2. Set the delimiter your file uses: tab, pipe, semicolon, comma or another character.
  3. Check the preview. Make sure each value sits in its own column and the header row looks right.
  4. Download the .csv file. It is written as UTF-8 with proper quoting, so values containing commas stay in one field.

The converter only accepts text files and checks the file before processing it, so you cannot accidentally feed it a renamed spreadsheet or an image.

Why does a browser-only converter matter for privacy?

The conversion runs on your own device. Your file is never uploaded to our servers and nothing is stored. That matters because TXT exports are often contact lists, customer records, payroll extracts or bank data. Uploading those to an unknown converter site creates a copy you no longer control.

A worked example from our own client work

A typical case for us: a client exports their contacts from an older CRM and sends a file called contacts.txt. It is tab-delimited with columns for name, company, email, phone and ZIP code. Some company names contain commas, such as “Smith, Jones & Partners”, and many ZIP codes start with zero.

  1. We confirm the tabs in a text editor, then run the file through the converter with the delimiter set to tab.
  2. In the preview we check that “Smith, Jones & Partners” stays in one cell.
  3. We download the CSV and open it in a text editor, not Excel, to confirm the ZIP codes still start with 0.
  4. The list is larger than the client’s email platform allows in one import, so we cut it into parts with the CSV splitter.

Next comes verification and deduplication. To hand that job over, our data cleansing services team cleans and standardises lead lists like this one.

How do you convert a text file to CSV in Excel?

Excel is the method most people reach for. Microsoft documents both the import and export steps in its guide to importing or exporting text files. In Microsoft 365 and recent versions:

  1. Open a blank workbook and go to Data > From Text/CSV (in the Get & Transform Data group).
  2. Select your .txt file and click Import.
  3. In the preview window, set File Origin to 65001: Unicode (UTF-8) if you see garbled accented characters, and choose the correct Delimiter, including Custom for pipes or Fixed Width.
  4. To protect leading zeros, click Transform Data, select the ZIP, phone or ID columns, and change their data type to Text. Then click Close & Load.
  5. Go to File > Save As (or Save a Copy), choose CSV UTF-8 (Comma delimited) (*.csv) and save.

Pick CSV UTF-8 over plain “CSV (Comma delimited)”, which uses a legacy encoding that can turn names like José into question marks.

Prefer the older wizard? You can turn it back on under File > Options > Data > Show legacy data import wizards, which adds a Legacy Wizards entry with “From Text (Legacy)” under Data > Get Data.

Why does Excel remove leading zeros from my CSV?

Excel guesses data types. A ZIP code like 02134 or a phone number like 0207 looks like a number, so Excel drops the zero. Setting those columns to Text during import keeps them. Be aware that double-clicking a CSV to open it in Excel strips the zeros again on screen, even if the file itself is fine. Check the saved file in a text editor before you assume it is broken.

How to convert TXT to CSV in Google Sheets

Sheets is a good free option if the file is not confidential.

  1. Open a new spreadsheet and go to File > Import > Upload, then select the .txt file.
  2. Choose an import location such as “Replace spreadsheet” or “Insert new sheet(s)”.
  3. Set Separator type to Detect automatically, Tab, Comma or Custom (type | for pipe files).
  4. Untick Convert text to numbers, dates, and formulas if your file has ZIP codes, phone numbers or IDs with leading zeros.
  5. Click Import data, review the sheet, then go to File > Download > Comma-separated values (.csv).

Can you convert TXT to CSV in Notepad by renaming the file?

Yes, but only when the text is already comma-separated. Renaming changes the label, not the content.

  1. Open the file in Notepad.
  2. Go to File > Save As.
  3. Set “Save as type” to All files (*.*), otherwise Notepad may save it as file.csv.txt.
  4. Type a name ending in .csv and choose UTF-8 encoding.

If the file uses tabs or pipes, renaming leaves every row in column A. Notepad’s Replace (Ctrl+H) can swap pipes for commas, but find-and-replace does not add quotes, so a value like “Acme, Inc.” becomes two columns.

On a Mac, open tab-delimited files in Numbers and use File > Export To > CSV.

How do you convert TXT to CSV in LibreOffice Calc?

  1. Open the .txt file in Calc to get the Text Import dialog.
  2. Set the character set (usually UTF-8) and the separator, or choose Fixed width and click to set column breaks. Set ZIP and phone columns to Text.
  3. Choose File > Save As > Text CSV (.csv), with comma as the field delimiter.

How to convert a TXT file to CSV with Python

Python is the best choice for repeat jobs or large files. The built-in csv module handles quoting for you, so you do not need any extra packages.

import csv

with open("input.txt", newline="", encoding="utf-8") as src, \
     open("output.csv", "w", newline="", encoding="utf-8") as dst:
    reader = csv.reader(src, delimiter="\t")   # use "|" or ";" for other files
    writer = csv.writer(dst)                   # commas, quotes added where needed
    writer.writerows(reader)

Three details make this reliable:

  • newline=”” on both files stops blank lines appearing between rows on Windows, as the Python docs recommend.
  • csv.writer quotes any value containing a comma, quote or line break automatically.
  • Everything is read as text, so leading zeros survive. Use encoding="utf-8-sig" for the output if Excel users will open it, since the byte order mark helps Excel detect UTF-8.

For fixed-width files, pandas is simpler. Pass the column widths and read everything as strings:

import pandas as pd

df = pd.read_fwf("input.txt", widths=[20, 30, 10], dtype=str)
df.to_csv("output.csv", index=False)

For delimited files the pandas version is pd.read_csv("input.txt", sep="\t", dtype=str).to_csv("output.csv", index=False). Leave out dtype=str and pandas converts ZIP codes to numbers; leave out index=False and you get an extra unnamed index column.

How to convert TXT to CSV from the command line

Windows PowerShell

PowerShell’s Import-Csv reads any delimited text file when you pass -Delimiter:

# Tab-delimited (the backtick-t is a tab in PowerShell)
Import-Csv -Path .\input.txt -Delimiter "`t" |
  Export-Csv -Path .\output.csv -NoTypeInformation -Encoding UTF8

# Pipe-delimited
Import-Csv -Path .\input.txt -Delimiter '|' |
  Export-Csv -Path .\output.csv -NoTypeInformation -Encoding UTF8

Import-Csv treats the first line as headers; if your file has none, add -Header Name,Email,Phone. -NoTypeInformation removes the “#TYPE” line Windows PowerShell 5.1 adds (PowerShell 7 omits it by default).

Mac and Linux terminal

The quick one-liner is tr '\t' ',' < input.txt > output.csv, but like Notepad’s replace, it does not quote values, so it is only safe when no field contains a comma. For real data, install csvkit and run csvformat -t input.txt > output.csv for tab files or csvformat -d "|" input.txt > output.csv for pipe files. It writes properly quoted CSV.

Which method should you use? A comparison

Method Cost Upload needed? Keeps leading zeros Best for
LeadCanal browser tool Free No, runs locally Yes Quick, private one-off conversions
Excel Paid (Microsoft 365) No Only if set to Text Files you also want to edit or review
Google Sheets Free Yes, to Google Drive If conversion is unticked No Excel, non-sensitive files
LibreOffice Calc Free No If set to Text Fixed-width and odd encodings
Notepad rename Free No Yes Files already comma-separated
Python Free No Yes Large files and repeat jobs
PowerShell / csvkit Free No Yes Scripts and server automation

What limits should you know before converting large files?

CSV itself has no row limit, but the apps you open it in do.

Where the CSV goes Limit What to do
Excel worksheet 1,048,576 rows by 16,384 columns (Excel specifications) Split the file or use Python
Google Sheets 10 million cells per spreadsheet Split before importing
Email and CRM importers Varies by platform, check its import help page Cut it into batches with a CSV splitter

If a file is too big for your import screen, the free CSV splitter divides it into smaller files you can import one at a time.

Troubleshooting: why does my converted CSV look wrong?

  • Everything is in column A: the wrong delimiter was used. Re-import and pick tab, pipe or semicolon.
  • Columns shift on some rows: a value contains the delimiter or a comma without quotes. Use a quoting-aware tool, not find-and-replace.
  • Strange characters like é or ?: an encoding mismatch. Import as UTF-8 and save as CSV UTF-8.
  • Leading zeros missing: set those columns to Text on import, or check the file in a text editor, since Excel hides them on screen.
  • Long numbers show as 1.23E+15: Excel converted an ID or card-style number to scientific notation. Import that column as Text.
  • Blank line between every row: in Python, open the output with newline="".
  • Semicolons instead of commas after saving: your system’s list separator is set to semicolon, common in European regional settings. Change it or use a converter that always writes commas.

What can you do with the CSV once it is converted?

A clean CSV is usually a step, not the destination:

  • Need JSON for an API or app instead? Use the TXT to JSON converter.
  • Turning a contact list into phone contacts? The CSV to VCF converter creates vCards you can import into iPhone, Android or Outlook.
  • Your text file is messy notes rather than a table? Pull the addresses out with the email extractor first, then convert.
  • Planning to email the list? Run it through the email verifier before importing it into your sending tool.

All of these run in the browser too. You can find the full set on our free tools page.

Frequently asked questions

Can you convert TXT to CSV for free?

Yes. A browser-based converter, Google Sheets, LibreOffice Calc, Python and PowerShell are all free. Excel works too if you already have it.

How do I convert a TXT file to CSV without Excel?

Use the LeadCanal browser converter, Google Sheets (File > Import), LibreOffice Calc, or a short Python or PowerShell script. None of them need Excel.

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

Choose Tab as the delimiter in your converter, Excel or Sheets import, or use delimiter="\t" in Python and -Delimiter "`t" in PowerShell.

How do I keep leading zeros when converting TXT to CSV?

Import ZIP, phone and ID columns as Text, or use a tool that treats every value as text. Then check the result in a text editor, because Excel hides leading zeros when it opens a CSV.

Is it safe to convert files with an online converter?

It depends whether the file is uploaded. Our converter processes the file in your browser, so it never leaves your device. With upload-based sites, check their privacy policy before sending contact or financial data.

Can I convert several TXT files to CSV at once?

Yes, with a script. Loop over the files in Python, or in PowerShell use Get-ChildItem *.txt and run Import-Csv and Export-Csv on each one.

Conclusion: key takeaways

Learning how to convert TXT to CSV comes down to spotting the delimiter and protecting your data on the way through.

  • Identify the delimiter first: tab, pipe, semicolon or fixed width.
  • Use a quoting-aware tool; find-and-replace breaks values that contain commas.
  • Import ZIP, phone and ID columns as Text to keep leading zeros.
  • Save as CSV UTF-8 so accented names and symbols stay readable.
  • Use a browser-only converter for contact lists and other private files.
  • Split files that exceed Excel, Google Sheets or importer limits before you import them.

Key takeaways

How to convert TXT to CSV

1 Identify the delimiter first: tab, pipe, semicolon or fixed width.
2 Use a quoting-aware tool; find-and-replace breaks values that contain commas.
3 Import ZIP, phone and ID columns as Text to keep leading zeros.
4 Save as CSV UTF-8 so accented names and symbols stay readable.
5 Use a browser-only converter for contact lists and other private files.
6 Split files that exceed Excel, Google Sheets or importer limits before you import them.

Editorial policy

We write guides about the files and data we work with every day. Each method here was checked against current product documentation and tested on real text exports. We update the guide when these apps change their steps, and we do not accept payment to recommend tools.

Content transparency

This article was researched with keyword and search data and checked against official documentation from Microsoft, Python and the CSV specification. LeadCanal built and offers the free browser tools mentioned, including the TXT to CSV converter. Other methods are included because they are genuinely useful.

About the author

This guide was written by the LeadCanal team. We build verified B2B contact lists, enrich CRM data and run cold email infrastructure every day, so we convert, split and repair CSV, TXT and VCF files for clients constantly. We built our free converters to do that work privately in the browser.

Found this useful? Share it with your team.

Written by LeadCanal

The LeadCanal team builds verified B2B lists and runs cold email infrastructure for agencies and sales teams. Every guide comes from campaigns we send every day.

Done-for-you lead generation

Want this done for you?

Targeted lists and cold email campaigns that book qualified meetings.