๐ CSV Fundamentals ยท 7 min read
CSV vs TXT: What's the Difference?
Both are plain text, and the bytes are often identical. The difference is the promise the extension makes: .csv means records of comma-separated fields, registered as text/csvin RFC 4180, while .txt means only "this is text" with no claim about fields at all. That promise changes behaviour. Microsoft's own documentation says a .txt file starts the Import Text Wizard, and a .csv file opens straight into a workbook with the default data format applied to every column.
So the useful question is not which format is "better". It is which one keeps the receiving program from guessing wrong, and that depends on whether your file is actually a table.
What each extension promises
RFC 4180 gives CSV a real grammar. Section 2 defines the file as file = [header CRLF] record *(CRLF record) [CRLF] with record = field *(COMMA field): optional header line, then records, fields separated by the comma character, records ending in CRLF. It also allows an optional header parameter in the media type registration whose values are present or absent, so a CSV can even declare whether its first line is column names.
A .txt file declares none of that. It is plain text: the bytes are characters, line breaks are line breaks, and whether a comma or a tab means "next column" is entirely the reader's problem. This is not a weakness โ it is the point of a text file. But it explains why everything that has to parse data treats the two extensions differently.
What Excel actually does with each one
Microsoft's support article on importing and exporting text files is explicit about the split, and worth quoting because it settles most arguments:
"If the file is a text file (.txt), Excel starts the Import Text Wizard... If the file is a .csv file, Excel automatically opens the text file and displays the data in a new workbook."
The same article adds the part people rarely read: "When Excel opens a .csv file, it uses the current default data format settings to interpret how to import each column of data." No prompt, no preview, no choice of encoding. Whatever your regional settings think a date looks like is what you get.
The article then gives the workaround that tells you how mechanical all of this is: "To force Excel to run the Import Text Wizard, you can change the file name extension from .csv to .txt before you open it." The contents did not change. The route did.
CSV vs TXT side by side
| Property | .csv | .txt |
|---|---|---|
| Default field separator | Comma (RFC 4180) | Unspecified. Microsoft's guide notes tab (ASCII 009) is typical for delimited text |
| Registered media type | text/csv, optional charset and header parameters | text/plain |
| Can declare a header row | Yes, via the header parameter or by convention | No mechanism |
| Double-click in Excel | Opens directly, default formats applied | Import Text Wizard |
| Good fit for | Tables moving between systems | Logs, notes, one-value-per-line files, deliberate imports |
What we measured
We wrote one 40-byte file โ two records plus CRLF line endings โ three times, changing only the extension, then asked Python's mimetypes module what each one is. On 2026-10-31, Python 3.13.5:
| File name | Bytes | Type reported from extension |
|---|---|---|
data.csv | 40 | text/csv |
data.txt | 40 | text/plain |
data.tsv | 40 | text/tab-separated-values |
Three different types, one identical file. That is the whole mechanism of this article in a table: the extension is a label, and downstream software reads the label before it reads the bytes.
Two follow-up observations from the same session. First, a library that parses content rather than extensions does not care: pandas.read_csv() returned the same three-column frame from all three files, because it reads bytes and assumes a comma. Second, the label wins over the truth: we took a tab-separated file and named it tabs-named.csv. pandas, still assuming a comma, returned one column named id followed by a tab character and the word name. Passing sep="\t" returned two columns. Nothing was corrupt; the file simply was not the thing its name said it was.
When TXT is the better choice
A .txt is the right container when there is no table. If the file is a log with one event per line, a list of emails, a SQL dump you intend to pipe into something else, or notes that happen to contain commas, calling it .csv invites every importer on the machine to invent columns that do not exist.
It is also the honest choice for a file whose delimiter you want a human to choose. That is why the wizard exists. Tab-delimited text with a .txt extension says "this is text, work out the structure yourself" โ which is exactly the behaviour you want when you are about to check every column type by hand.
When renaming is the wrong fix
Renaming fixes routing, not content, and it has three traps.
Hidden extensions. Windows hides extensions by default, so a file displayed as data.csv may really be data.csv.txt. Turn on View > Show > File name extensions before you rename anything, or you will end up with two extensions and a file that still will not open where you expect. Why your CSV behaves like a text file covers that failure in detail.
The default format problem. A .csv that opens straight into Excel gets each column interpreted with your regional defaults. Leading zeros disappear, long numbers turn into scientific notation, and day-first dates may swap. None of this happens in the file; it happens on the way in. If any of those columns matter, rename to .txt first and set the types in the wizard, or import through Data > From Text/CSV.
Delimiter mismatch. If the fields are separated by semicolons or tabs, renaming to .csv produces a file that claims commas and contains none. Fix the delimiter itself: the delimiter converter rewrites the separators with proper quoting, which is safer than find-and-replace on any file where values contain commas. The delimiter options guide explains which separator a given export tends to use.
Converting between the two
Going from a real CSV to a tab-delimited .txt is a delimiter change, not a format change: same rows, same order, different separator. The converter does that in the browser and quotes fields that need it. Going the other way โ a delimited text file into CSV โ is the same operation with the separator set to tab. Converting text to CSV walks through it, and the RFC 4180 walkthrough explains what a valid CSV must contain.
One habit that prevents most of these problems: decide the extension from the content before the file leaves your machine. If a system exports tab-separated data as export.csv, convert it once, at the source of the confusion, instead of explaining the mismatch to every person who opens it later.
Frequently Asked Questions
Is a CSV file just a text file with a different extension?
In terms of bytes, often yes. RFC 4180 defines CSV as text with one record per line, fields separated by commas, and registers the media type text/csv. A .txt file makes no claim about fields at all. So the physical content can be identical while the extension changes what a program expects to find inside, which is why the same bytes can open as a table in one place and as one long line in another.
Why does Excel open my .txt in a wizard but my .csv straight into a sheet?
That is Excel's documented behaviour. Microsoft's guide to importing and exporting text files says that for a .txt file Excel starts the Import Text Wizard, and that for a .csv file Excel opens the file automatically and displays the data in a new workbook, interpreting each column with the current default data format. The wizard exists because a .txt does not tell Excel where the fields are.
How do I force Excel to run the Import Text Wizard on a CSV?
Microsoft documents two ways: rename the file extension from .csv to .txt before opening it, or connect to the file as an external data range instead of double-clicking it. The rename trick works because the extension is what routes the file to the wizard, not the contents. If that is the behaviour you always want, keep the data as .txt and import it deliberately.
Does the file extension change the data inside the file?
No. Renaming does not rewrite a single byte. We wrote the same 40 bytes three times as data.csv, data.txt and data.tsv and confirmed the sizes stayed identical; only the type reported from the extension changed, from text/csv to text/plain to text/tab-separated-values. What changes is how the receiving program guesses at the structure, and a wrong guess can lose leading zeros, mangle dates or collapse every column into one.
Which is better for data, CSV or TXT?
Use .csv when the file is a table that other systems will read: the comma grammar is specified, the media type is registered, and spreadsheet programs and importers recognise it without configuration. Use .txt when the content is not a table at all, or when you want the receiving human to choose the delimiter and column types on the way in. A tab-delimited .txt is common for exactly that reason.
My data has tabs instead of commas. Should I rename it .csv?
No. A tab-separated file called data.csv reports itself as text/csv and then fails the comma grammar it just claimed to follow. Measured: a two-line tab-separated file renamed to .csv arrived in pandas as a single column named id followed by a tab and the word name. Convert the delimiter instead of renaming, so the file and its extension tell the same story.
Sources
- RFC 4180, Common Format and MIME Type for CSV Files, section 2 (ABNF grammar: optional header, records separated by CRLF, fields separated by COMMA) and section 3 (registration of
text/csvunder thetextmedia type; optionalcharsetandheaderparameters with values present or absent; "Common usage of CSV is US-ASCII"). Retrieved 2026-10-31. - Microsoft Support, Import or export text (.txt or .csv) files: delimited text files (.txt) typically use tab (ASCII 009) and CSV files use the comma; a .txt opened in Excel starts the Import Text Wizard, a .csv is opened automatically into a new workbook using the current default data format settings; to force the wizard on a CSV, change the extension to .txt; import and export are supported up to 1,048,576 rows and 16,384 columns. Retrieved 2026-10-31.
- Local measurement, 2026-10-31, Python 3.13.5: one 40-byte file written as
data.csv,data.txtanddata.tsv;mimetypes.guess_typereturnedtext/csv,text/plainandtext/tab-separated-values; pandas 2.3.3 read all three as shape (2, 3) with columns id, name, city; a tab-separated file namedtabs-named.csvread as shape (1, 1) with the single columnid\tname, and as shape (1, 2) withsep="\t".
Check What Your File Really Is
The analyzer reports the delimiter it found, the encoding, and how many rows it parsed โ so a file named .csv that is really tab-separated shows up as one column immediately rather than after an import fails somewhere else.
Related reading
Format Conversion โ other guides that pair well with this one.
- Convert CSV to PDF
- Convert CSV to Excel Without Excel
- Excel CSV Separator Setting: Why a Comma-Delimited File Has No Commas
- Convert Excel to CSV Free Online
Browse all guides in the NoCodeCSV blog.