How to convert CSV to Excel
Updated · 3 min read
Double-clicking a CSV file makes Excel guess what each value means, and it often guesses wrong. Converting the CSV into a real .xlsx workbook first stores every value with the right type, so the file opens exactly as intended for you and for anyone you send it to.
- Paste the CSV text or drop a
.csv/.txtfile onto the input box. - The delimiter (comma, semicolon, tab or pipe) is detected automatically — check the Delimiter statistic below the editors.
- Review the preview: one line per row, columns separated by tabs.
- Click Download to save the
.xlsxworkbook.
Example
CSV input
product_code;description;quantity;price
00125;"Cable, USB-C 2m";40;7.90
00480;Câble HDMI 4K;12;12.50
1234567890123456789;Gift card;1;50Excel output
| product_code | description | quantity | price |
|---|---|---|---|
| 00125 | Cable, USB-C 2m | 40 | 7.9 |
| 00480 | Câble HDMI 4K | 12 | 12.5 |
| 1234567890123456789 | Gift card | 1 | 50 |
This semicolon-separated file is detected automatically. The product codes keep their leading zeros and the 19-digit code stays intact — opening the CSV directly in Excel would display 125, 480 and 1.23457E+18 instead.
Your data stays on your device. The conversion runs in JavaScript inside this tab — files and pasted text are never uploaded to DataSwitch Pro.
Why not just open the CSV in Excel?
When Excel opens a CSV directly, it applies its own interpretation to every cell:
- Leading zeros are removed:
00125becomes 125. - Long numbers are shown in scientific notation and digits after the 15th are lost.
- Values such as
3-4orMAR1are silently turned into dates. - UTF-8 text without a byte-order mark shows up as é instead of é.
- A file with the "wrong" separator for your region lands entirely in column A.
This converter only types values that are unambiguously numbers or booleans, keeps everything else as text, and writes the result into a workbook where Excel no longer has to guess.
Delimiters and encodings
The delimiter is detected by checking which character splits every line into the same number of fields. Files exported by Excel in Unicode (UTF-16) or by older software in Windows-1252 are recognised and decoded automatically when you upload them, so accented characters come through intact.
The generated workbook
The workbook contains one sheet named Data with a bold, frozen header row and columns sized to their content. Numbers and booleans are real typed cells, so formulas and pivot tables work right away. Values that start with =, + or @ are stored as plain text, which also protects you from CSV formula injection.
Convert CSV to Excel in code
For one-off files the tool above is quickest. To automate the same task in a script or pipeline, these snippets are a good starting point.
Python (pandas)
import pandas as pd # pip install pandas openpyxl
# dtype=str keeps leading zeros and long codes exactly as written
df = pd.read_csv("data.csv", sep=None, engine="python", dtype=str)
df.to_excel("data.xlsx", index=False)
Node.js
// npm install csv-parse write-excel-file
import { readFileSync } from "node:fs";
import { parse } from "csv-parse/sync";
import writeXlsxFile from "write-excel-file/node";
const rows = parse(readFileSync("data.csv"), { bom: true, delimiter: ";" });
await writeXlsxFile(rows).toFile("data.xlsx");
Frequently asked questions
Can I paste CSV instead of uploading a file?
Yes. Paste the text into the input box; the delimiter is detected and the preview updates as you type.
Are formulas in the CSV executed?
No. Text that looks like a formula is stored as a text cell, so a malicious value such as =HYPERLINK(…) cannot run when the workbook is opened.
How many rows can I convert?
An Excel sheet holds up to 1,048,576 rows. The converter itself has no server limit; very large files depend on your device's memory.
Can I keep every value as text?
Yes. Untick Detect numbers & booleans in Options and every cell is written as text.
Does it work with TSV files?
Yes. Tab-separated files are detected automatically, or select TSV as the source format.