Home › Developer Tools › Text to CSV Converter

Text to CSV Converter

Paste command output, a fixed-width export, a pipe-delimited file or any text arranged in columns and get a proper CSV file. Columns are detected automatically, and you can set exact column positions on a ruler when the data needs it.

Last updated:

Cleanup and output options
Column preview
Advertisement
Advertisement

How to use the Text to CSV Converter

  1. Paste your text or open a .txt file. A sample report is loaded so you can see how it works.
  2. Check the detected split shown next to the input title. Change Split columns by if the guess is wrong.
  3. For fixed-width data, pick Fixed width and click the ruler to place column breaks, or type the start positions.
  4. Clean up with the options: skip title lines, ignore comments, drop rule lines and trim spaces.
  5. Review the column preview; rows highlighted in orange have an unusual number of columns.
  6. Download the CSV or copy it into your spreadsheet, database import or script.

Which split mode fits your text?

Your text looks likeUseWhy
Tokyo⇥Japan⇥Asia (copied from a spreadsheet)TabSpreadsheets and many exports put a tab between cells.
| 1 | Notebook | 3.50 |Pipe |Console tables, Markdown tables and many bank or EDI exports use pipes.
A-1001   Desk lamp   12Spaces, 2+ gapColumns are separated by wide gaps, while single spaces stay inside values.
user1 pts/0 10:22Spaces, any runValues never contain spaces, as in most command-line output.
00012345JOHNSON   MARYFixed widthEach field always starts at the same character position, often with no gap at all.
id::name::price or mixed separatorsCustomAny string works, and a regex such as \s*[;|]\s* covers several separators at once.

Working with fixed-width files

Fixed-width (also called column-aligned or flat) files come from mainframes, payroll and banking systems, government data sets and old report printers. A record layout document usually lists each field with a start position and a length, for example Last name: positions 9-18. To convert such a file, choose Fixed width and type the start position of every column except the first, counting from 1. For the layout above you would enter 9 for the last name. The ruler numbers the characters so you can check that each break sits exactly where a field begins.

When the columns are separated by blank space, Detect columns finds every character position that is blank on all lines and places a break where text starts again. If a long title line or a note spans several columns, use Skip first lines or the comment prefix to keep it out of the detection.

Tips for a clean CSV

  • Keep the header: if the first line holds the column names, leave First row is a header ticked so the preview labels the columns. The header is still written to the CSV as its first row.
  • Watch the orange rows: a row with a different number of fields usually means an empty cell in space mode, a stray delimiter inside a value, or a summary line such as 3 rows in set that you can remove.
  • Leading zeros: CSV stores text, so 00012345 stays intact in the file. Excel may still drop the zeros when it opens the file; import the column as Text to keep them.
  • Big files: the converter handles files with many thousands of lines; the preview shows the first 200 rows while the download contains all of them.

Already have CSV that needs a different delimiter? Use the TSV to CSV Converter. To inspect or tidy the result, open it in the CSV Viewer or the CSV Cleaner.

Frequently asked questions

How do I convert a TXT file to CSV?

Open the .txt file or paste its contents. The tool detects how the columns are separated (tabs, pipes, commas, aligned spaces or fixed positions) and writes CSV in the output box. Check the preview, then click Download .csv.

What is the difference between space-delimited and fixed-width text?

In space-delimited text the columns are separated by one or more spaces, so a value can be found by splitting on the gaps. In fixed-width text every column occupies the same character positions on every line, and values may touch each other with no space at all. Fixed-width files need column positions instead of a delimiter.

Why do some rows have fewer columns in space mode?

When a cell is empty, the gap between its neighbours just gets wider, so splitting on spaces cannot tell that a value is missing and the remaining values shift left. Switch to Fixed width: it cuts every line at the same positions, so empty cells stay empty.

How do I convert a table copied from a terminal or a SQL client?

Paste it as it is. Lines made of dashes, equals signs or +----+ borders are dropped, and the leading and trailing pipes are removed, so only the data rows remain. Box-drawing characters such as │ are treated like pipes.

Can a value contain a comma?

Yes. In the CSV output any value containing the delimiter, a double quote or a line break is wrapped in double quotes, and inner quotes are doubled, following RFC 4180. Spreadsheet apps read these values back correctly.

Which output delimiter should I choose for Excel?

Comma works in most setups. If your Excel uses a comma as the decimal separator (common in Europe), choose Semicolon so Excel splits the columns when you double-click the file, and tick Add UTF-8 BOM so accented characters display correctly.

Is my file uploaded?

No. The file is read and converted by JavaScript in your browser tab, and nothing is sent to a server.

Are all the tools on FreeToolCabin tested for quality and accuracy?

Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

Related tools

TSV to CSV ConverterConvert TSV to CSV and back, or between tab, comma, semicolon and pipe, with correct quoting.CSV ViewerOpen a CSV or TSV file as a sortable, filterable table.CSV CleanerClean messy CSV in one click: trim spaces, drop empty rows and columns, fix headers, dedupe.CSV to Excel ConverterConvert CSV files to a real .xlsx workbook with typed numbers and dates, one sheet per file.JSON to Excel ConverterTurn JSON into a styled .xlsx spreadsheet; nested arrays become their own linked sheets.JSON to CSVConvert JSON data to CSV for spreadsheets.CSV to JSONConvert CSV data to JSON with live preview.Excel to CSVConvert XLSX spreadsheets to CSV.Excel Viewer (XLSX / XLS)Open XLSX, XLS and ODS spreadsheets in your browser without Excel.Line Ending ConverterConvert text and files between CRLF, LF and CR line endings.Markdown to HTMLConvert Markdown to clean HTML with a live editor.XML to JSONConvert XML to JSON with validation.Text Encoding ConverterDetect and convert text file encodings like UTF-8, UTF-16 and Latin-1.JSON ViewerExplore JSON as a collapsible tree, search keys and values and copy any node's path.TTF to WOFF2 ConverterConvert TTF and OTF fonts to WOFF2 or WOFF and get a ready @font-face CSS snippet.Chmod CalculatorConvert Linux file permissions between checkboxes, octal (755) and symbolic (rwxr-xr-x) notation.JSON to TypeScriptGenerate TypeScript interfaces or types from JSON, with nested types and optional fields.Morse Code TranslatorTranslate text to Morse code and back, then play it as sound or a blinking light, or save a WAV.HTML Table GeneratorBuild HTML tables in an editable grid with styles, header rows, CSV import and live preview.Hex to Text ConverterConvert hex to text and text to hex with UTF-8 support and space, 0x, \x or comma formats.JSON to XML ConverterConvert JSON to well-formed XML with attributes, arrays and pretty print.JSON to YAML ConverterConvert JSON to clean YAML as you type, with indent, quoting and sort options.YAML to JSON ConverterConvert YAML to pretty or minified JSON, with errors pinned to the exact line.HTML to Markdown ConverterTurn HTML or pasted rich text into clean Markdown with tables and live preview.Markdown Table GeneratorBuild Markdown tables in a grid or paste from Excel/CSV, with alignment and preview.JSON ValidatorCheck JSON with the exact line and column of each error, fix tips and one-click auto-fix.Image to Base64Convert images to Base64 data URIs, CSS backgrounds and HTML img tags in your browser.Base64 to ImagePaste a Base64 string or data URI to preview, identify and download the image.JSON CompareCompare two JSON documents and see every added, removed and changed path.Hex to DecimalConvert hex to decimal instantly with steps and signed mode.Decimal to HexConvert decimal to hex instantly with steps and signed mode.Binary to DecimalConvert binary to decimal instantly with steps and signed mode.Decimal to BinaryConvert decimal to binary instantly with steps and signed mode.Two's Complement CalculatorDecimal to two's complement binary and back for 4-64 bits, with invert-and-add-1 steps.XML to CSV ConverterConvert XML to CSV: detects repeating records, flattens nested data, pick your columns.CSV to XML ConverterConvert CSV to well-formed XML with custom root and row names, escaping and pretty print.TOML to JSON ConverterConvert TOML to JSON and JSON to TOML with a full v1.0 parser and clear error lines.JSON to Go StructTurn JSON into Go structs with inferred types, nested structs and json tags.CSV TransposeSwap rows and columns of CSV, TSV or pasted spreadsheet data, with delimiter auto-detect.Date Format ConverterConvert any date to ISO 8601, RFC 2822, Unix time and custom strftime, moment or Java patterns.ENV to JSON ConverterConvert .env files to JSON or YAML and JSON back to .env, with quotes and multiline values.File to Base64Convert any file to a Base64 string or data URI with MIME detection, line wrap and download.HTML Table to CSVExtract any table from HTML or page source to CSV, TSV or JSON, with colspan and rowspan handled.IEEE 754 Floating Point ConverterConvert decimals to 32/64-bit IEEE 754 floats: toggle bits, see hex, exact value and rounding error.INI to JSON ConverterConvert INI and CFG files to JSON and JSON back to INI, with sections, arrays and types.IP Address ConverterConvert IPv4 to decimal, hex, binary, octal and back, with class and private/public check.ISBN Converter & ValidatorConvert ISBN-10 to ISBN-13 and back, validate check digits and hyphenate, one or in bulk.JSON Flatten / UnflattenFlatten nested JSON to dot or bracket path keys, or unflatten flat keys back to nested JSON.JSON to Dart ClassTurn JSON into Dart model classes with fromJson, toJson, null safety and nested classes.JSON to Java ClassTurn JSON into Java POJOs or records with Lombok, getters/setters and Jackson or Gson annotations.JSON to Kotlin Data ClassTurn JSON into Kotlin data classes for kotlinx.serialization, Gson, Moshi or Jackson.JSON to Markdown TableTurn a JSON array of objects into a GitHub Markdown table with column picker and alignment.JSON to PHP ArrayConvert JSON to PHP array code (short [] or array()) and PHP arrays back to JSON.JSON to Rust StructTurn JSON into Rust structs with serde derives, rename attributes, Option and Vec types.JSON to SQL ConverterConvert a JSON array of objects to CREATE TABLE and INSERT statements for MySQL, Postgres, SQLite.JSON to Swift StructTurn JSON into Swift Codable structs with CodingKeys, optionals and nested types.JSON to TOML ConverterConvert JSON to clean TOML with tables, arrays of tables, inline tables and dates.JSONL to JSON ConverterConvert JSON Lines / NDJSON to a JSON array and back, with line-level error reports.Properties to YAML ConverterConvert Java .properties to nested YAML (application.yml) and YAML back to properties.PX to EM ConverterConvert pixels to em using the parent font size, and em back to px, with conversion tables.Query String to JSONConvert URL query strings to JSON with nested brackets and arrays, and JSON back to a query string.REM to PX ConverterConvert CSS rem values to pixels for any root font size, with a quick 0.25–6rem table.SQL to JSON ConverterConvert SQL INSERT statements and dumps into a JSON array of row objects, with CSV export.TypeScript to JavaScriptConvert TypeScript or TSX to clean JavaScript instantly: strip types, keep or compile JSX.XML to YAML ConverterConvert XML to clean YAML with attributes, text nodes, lists and exact error lines.YAML to XML ConverterConvert YAML to pretty, well-formed XML with custom root, attributes and array item tags.Boolean Algebra SimplifierSimplify boolean expressions or minterm lists to minimal SOP and POS with Quine-McCluskey steps.Compare Excel FilesCompare two Excel spreadsheets cell by cell, highlight changes and export a diff report.
See all 129 Data & File Format Converters →