Excel Deleted Leading Zeros in My CSV — How to Keep Them
Your zip codes say 2139 instead of 02139. Product SKUs lost their prefixes. Phone numbers shed their leading zero. The file was fine when you received it — Excel ate the zeros the moment it opened the file. Here's what's going on and how to stop it.
The guessing problem
A CSV file is plain text — it carries no information about whether 02139 is a number or a piece of text. So when Excel opens a CSV, it guesses each column's type. Anything that looks numeric becomes a number, and numbers don't have leading zeros. The cruel part: if you then save the file, the zeros are destroyed permanently. The original text is gone.
The damage, step by step
- CSV contains
02139(5 characters of text) - Excel opens it, guesses "number" → displays
2139 - You press Save → the file now literally contains
2139 - The zero is unrecoverable — unless every code was exactly 5 digits
How to keep them
The fix has two halves: repair the structure without touching values, and open the result in a way that respects text.
- Run the file through the CSV Repair Tool — it never converts values to numbers, so
02139survives parsing byte-for-byte. Keep the "Keep all values as text" option on. - Download the repaired file. The tool writes zero-leading fields in a form Excel displays literally.
- Going forward, never double-click a CSV with codes in it. In Excel use Data → From Text/CSV and set the code columns to Text before loading. In Google Sheets, choose "plain text" for those columns in the import dialog.
The rule to remember
A CSV's text is the truth; any program's interpretation is a guess. The damage happens at open time, not at repair time — which is why a repair tool that refuses to guess types is the safe middle step. Once zeros are stripped and saved, no tool can bring them back.
Two cases, two outcomes
Not every lost zero can be recovered. Which case you're in decides what to do. Use a clearly made-up product code — A-00123 — as the test:
Case 1: the zeros are still in the file (recoverable)
Open the CSV in a plain text editor. If you see A-00123 with the zeros intact, the file itself is fine — only the spreadsheet's display ate them. Run it through the CSV Repair Tool, which never converts values to numbers, then import the result with the code column set to Text. Zeros kept.
Case 2: the zeros are gone from the file (not recoverable)
If the text editor shows A-123, someone opened and re-saved the file in a spreadsheet. The original zeros no longer exist anywhere — no tool can restore digits that were never stored. The only fix is the source: re-export from the original system, or ask the sender for the untouched file.
Confirm the fix worked
- Check the original in a text editor first. Zeros present means Case 1 — fixable. Zeros already gone means Case 2 — stop and re-export.
- After repair, open the download in a text editor again.
A-00123must still readA-00123, byte for byte. If it doesn't, the tool guessed a type — ours won't, but check anyway. - Import via Data → From Text/CSV with the code column set to Text. The cell shows
A-00123, notA-123. - Guard the repaired file. If you ever re-save it with that column as General, the zeros are destroyed (Case 2). The fix is a workflow change, not a one-time repair.
🔧 Check whether your file still has its zeros intact:
Run the CSV Repair Tool →FAQs
Why does Excel remove leading zeros from CSV files?
When Excel opens a CSV, it guesses each column's data type. A value like 02139 looks numeric, so Excel converts it to the number 2139. CSV files store no type information, so Excel has nothing to tell it the value was meant as text.
Can I get the zeros back after Excel removed them?
Only if you know exactly how many digits each value should have — then you can pad them back with a formula like TEXT(A1,"00000"). But if some codes are 5 digits and others are 4, the information is genuinely lost. Prevention is the only reliable fix.
Does Google Sheets do the same thing?
Yes, Google Sheets also auto-detects types on CSV import, though its import dialog lets you set column types to 'plain text' before the data loads. That setting is the key: declare text columns as text at import time.
Last updated: 2026-10-04 · NumWhiz