Text to CSV Converter
Paste a block of text, or drop a .txt, .dat, .prn or .log file. Whether the columns are held apart by a character or by nothing but alignment, they come back as CSV. The layout is measured from your file, and you can overrule the answer.
Want to rename the columns or drop a few before exporting? Open the app
Three kinds of file, one complaint
People arriving at a page like this are holding one of three things. Most tools answer only one of them, which is why the search takes so long.
- A fixed width report. A mainframe extract, a COBOL copybook dump, an AS/400 spool file, a bank statement laid out the way that bank has laid them out since 1994. No separator anywhere; each field begins at a character position and is padded with spaces to a set length. The people who need this are usually migrating something old under a deadline.
- A delimited file that happens to end in .txt. Tabs, pipes or semicolons inside, and an extension that Windows attached when somebody saved out of Notepad. The content is already a table. Only the label is wrong, and only sometimes.
- A table held together by spaces. Console output, a copied terminal table, a summary block at the bottom of a log. One record per line, columns lined up by eye, punctuation nowhere in sight.
The advice you meet first is to rename the file, and it works in exactly one case: a file that already has commas between fields, where the extension was the only thing wrong. Rename anything else and you get a CSV with one immense column, because not a character of the content has changed. Splitting the line into fields is the job. Renaming skips the job.
Worked example: a fixed width extract
The kind of thing that turns up as EMPMAST.TXT with no documentation attached:
EMPNO LASTNAME DEPT HIREDATE
000145 OKAFOR D041 19980312
000146 MENON D041 20030721
000147 VANDENBERG D115 20110905
000148 NAIR D115 20190617
Layout left on Auto, and the CSV is:
EMPNO,LASTNAME,DEPT,HIREDATE
000145,OKAFOR,D041,19980312
000146,MENON,D041,20030721
000147,VANDENBERG,D115,20110905
000148,NAIR,D115,20190617
The note above the preview says read as fixed width (4 columns detected), 4 data rows, 4 columns. The boundaries it settled on are character positions 0, 8, 20 and 26, the only places where two or more blank characters run all the way down the block. VANDENBERG is why the third boundary sits at 26 and not sooner: it is the longest surname present, and a gap only counts when every line agrees it is blank. Employee numbers keep their leading zeros, because nothing here is ever read as a number.
Different shape, same page. A pipe-separated ticket export, also saved as .txt:
ticket|opened|assignee|summary
4821|2026-01-14|r.menon|Card declined, retry loop
4822|2026-01-15|s.okafor|Export stalls at 90%
4823|2026-01-15|p.nair|Duplicate invoice emailed
Auto finds the pipe, reports read as pipe-delimited, and writes:
ticket,opened,assignee,summary
4821,2026-01-14,r.menon,"Card declined, retry loop"
4822,2026-01-15,s.okafor,Export stalls at 90%
4823,2026-01-15,p.nair,Duplicate invoice emailed
The first summary contains a comma, so it comes out wrapped in quotes. The other two need no quotes and get none. That requoting is the step a rename can never perform, and it is why pipe files fall apart so loudly when something treats them as CSV on the strength of the extension.
How the layout gets worked out
Auto asks two questions in order and stops at the first clear answer.
The first is whether one character is doing the work. Comma, semicolon, tab and pipe are each counted across the first 200 non-blank lines, ignoring any that sit inside double quotes, and a candidate has to appear at least once per line and yield the same field count on nine lines in ten. Nine rather than ten, because a single mangled line at the bottom of a 50,000 line export should not sink an obvious guess. When two characters both qualify, the more consistent wins, and a tie goes to whichever produces more columns.
The second is about alignment. A character position counts as blank only when it is blank on every sampled line, so a run of them is a column of whitespace standing the full height of the block. Two in a row ends one field and starts the next. Two is the narrowest gap real reports use, and insisting on two is what stops a value with a single space inside it, a surname or a city, from being cut in half. Positions past the end of a short line count as blank, so ragged lines cost nothing.
If neither question lands, runs of spaces are tried as a separator, and failing that you get one column per line with a note saying so rather than a silent shrug. Every field is trimmed of its padding on the way out.
The Layout control overrides all of that. Delimiter takes the character route and lets you name the character, including two or more spaces. Fixed width takes the alignment route. The choice is not cosmetic: give a block where one line has a blank middle value to fixed width and the gap stays in the middle column, while runs of spaces slides the city left into the name column and pads the end. Slicing by position knows where a column belongs; counting separators only knows how many it found.
Going the other way, CSV to text
The reverse search sends people here too, and the answer is shorter than anyone expects. A CSV is already a text file. Open one in Notepad and it is all there; rename it to .txt and every byte stays where it was.
What is usually meant is a different separator. Something downstream wants tabs, or a colleague wants a block that pastes into Word and Outlook as a real table, which tab separated text does and comma separated text does not. The delimiter changer writes that and names the download .tsv. If a padded fixed width report is what was actually asked for, that is formatting rather than conversion, and nothing here produces one.
Things that catch people out
- Only the first 200 lines are measured. That keeps a 100 MB file responsive, and it means a second report appended to the bottom with a different layout goes unnoticed. The boundaries found at the top get applied all the way down. Split the file first if it holds two shapes.
- Two spaces inside a value split it. Under fixed width a value like North East is safe, because slicing happens at fixed positions. Under the two-or-more-spaces setting any double space inside a value becomes a column break, and the row shifts left from there on.
- Quotes are literal in fixed width mode. On the delimited route quotes do their normal job and a line break inside a quoted field is kept. On the alignment route a quote is just another character in a column, so it survives into the cell and gets escaped in the CSV, which looks alarming and is correct.
- Short lines are padded, and counted. A line stopping before the last column is filled out with empty cells and the result says how many did that. A large number there usually means the boundaries are wrong, not the data.
- Empty header cells get placeholder names. A blank in the header row becomes column_2, column_5 and so on, with a note counting them, since a nameless column is awkward for whatever reads the file next.
- Excel will undo the leading zeros. The download really does contain 000145, and double clicking it gets you 145. Bring the file in through Data, then From Text/CSV, and mark that column as text before the import runs.
Frequently Asked Questions
Can I just rename my .txt file to .csv?
Only when the file already puts commas between its fields, in which case the extension was the only thing wrong and renaming fixes it. A tab file, a pipe file or a fixed width report renamed to .csv opens as one very wide column, because renaming changes the label and not a single character of the content. Splitting the line into fields is the actual work, and that is what this page does.
What does fixed width mean, and how are the columns found?
A fixed width file has no separator. Each field starts at a fixed character position and is padded with spaces to a set length, which is how mainframe and COBOL era systems have always written reports. To find the boundaries, every character position is checked across the sampled lines and marked blank only if it is blank on all of them. A run of two or more blank positions is a column of whitespace going down the whole block, and a new field starts after it.
The layout was detected wrong. Can I force it?
Yes, that is what the Layout control is for. Auto tries a single character separator first and falls back to column alignment. Delimiter forces the character route and lets you name the character: comma, semicolon, tab, pipe, or two or more spaces. Fixed width forces the alignment route. Forcing a separator that is not really in the file gives you one column per line, which is the quickest way to confirm your guess was wrong.
Does the first line become the header?
Yes, always. The first non-blank line becomes the CSV header row, so a file that starts straight into data will have its first record used as column names. Paste a header line above the data first if that matters. Header cells that come out empty are given placeholder names like column_2, and the result says how many needed one.
Which files does it take, and how large?
The picker accepts .txt, .dat, .log, .prn, .csv and .tsv, and there is a paste box for when the table is sitting in your clipboard rather than on disk. The size ceiling is 100 MB with no row limit underneath it. Content is what decides the parsing, not the extension, so a .dat that turns out to be tab separated is read as tab separated.
How do I go the other way and turn a CSV into a txt file?
A CSV is already a plain text file, so renaming it to .txt changes nothing inside it and is perfectly safe. The reason people ask is usually that something downstream wants tabs rather than commas, and tab separated text also pastes into Word and Outlook as a real table. Our delimiter changer writes that, and names the download .tsv.
Related
Turn that text file into columns
Drop the file or paste the block, check the note that says how it was read, and download the CSV. No account, no queue, no watermark on the output.
Back to the converter