CSV Leading Zeros Disappear in Excel: Why It Happens and How to Fix It

Updated July 24, 2026 · By the CSVUndo team · 7 min read · Applies to Excel 2016–365 on Windows and Mac

You export a customer list, double-click the CSV, and every ZIP code from Massachusetts is suddenly short. 00501 is now 501. The SKU 007 your warehouse scans a hundred times a day is now just 7. Nothing crashed and Excel never asked permission — it decided your codes were numbers and threw the zeros away.

The good news: this damage is completely reversible. Here is why it happens, how to restore the zeros in about thirty seconds, and how to stop Excel from doing it again.

The symptom: 00501 becomes 501

Open a CSV by double-clicking it and any all-digit value that starts with a zero comes up short. A clean five-digit ZIP column turns into a ragged mix of three-, four- and five-digit values, with no warning dialog and no green error triangle:

What the file said        What Excel shows
zip,city                  zip,city
00501,Holtsville NY       501,Holtsville NY
02134,Boston MA           2134,Boston MA
90210,Beverly Hills CA    90210,Beverly Hills CA

At this moment the file on disk is still intact — the damage lives only in Excel's grid. It becomes permanent the second anyone presses Ctrl+S, because Excel writes its parsed values back into the text file. In practice that is the whole story of most damaged files: a teammate “just opened it to check something” and clicked Save on the way out.

Why Excel deletes leading zeros

A CSV file is nothing but text and commas. There is no schema, no cell types, no way for the file to declare “the zip column is text.” So every time Excel opens one, it guesses the type of every single cell, in isolation.

A cell containing only digits is parsed as a number — and to a calculation engine, leading zeros are mathematically meaningless. 00501 and 501 are the same quantity, so the zeros are discarded during parsing, before the value ever reaches your screen. This is worth stressing: it is not a display glitch. The cell does not contain 00501 shown badly; it contains the number 501, full stop. A ZIP code is an identifier that happens to be written in digits, but CSV gives Excel no way to know that.

The same guessing engine is behind Excel's other famous CSV crimes: long barcodes collapsing into scientific notation like 8.85909E+11 and part numbers such as MARCH1 silently turning into dates.

Where it bites hardest

Fix a damaged file now

Restore the zeros in your browser — free, nothing uploaded

The CSVUndo leading-zeros tool pads every damaged value back to its full width. Your file never leaves your device.

Open the leading-zeros fixer →
  1. Drop your CSV onto the tool, or paste the rows straight in.
  2. Click Analyze. Columns full of digit-only values with inconsistent widths get flagged as likely victims.
  3. In the column picker, tick each affected column and set its target width: 5 for US ZIP codes, 8 for GTIN-8, 9 for routing numbers, 13 for EAN-13.
  4. Click Repair & Download. Every short value is left-padded with zeros to the width you chose — 501 becomes 00501, while 90210 is left alone.
Padding works here because these codes have a known fixed width, so the repair is exact. One caution: the restored file is only safe until someone opens it in Excel and saves again. Send the repaired CSV onward as-is, or use the prevention steps below before editing it.

Prevent it on the next import

The import that actually works: Data → From Text/CSV

Never double-click a CSV that contains codes. Instead, open a blank workbook and use Data → From Text/CSV. In the preview window click Transform Data, select the ZIP or SKU column, set its Data Type to Text, then Close & Load. Declared as text, 00501 stays 00501.

The legacy Text Import Wizard (Data → Get Data → Legacy Wizards → From Text) does the same job: in step 3, highlight each code column and set Column data format to Text. Renaming the file from .csv to .txt before File → Open forces this wizard to appear too.

Why Format Cells → Custom “00000” is not a real fix

The advice you will find on every forum: select the column, Format Cells → Custom, enter 00000. The display instantly shows 00501 again and the problem feels solved. It is not. The cell still stores the number 501 — the format is a coat of paint that belongs to the workbook, not to the data.

Watch it fail: apply the format, then Save As → CSV. Excel writes what is displayed, so the exported file even contains 00501 — deceptively reassuring. Now close it and reopen the CSV: 501 again. A CSV cannot carry cell formats, so the padding evaporated on the round trip and this time there is no format left to hide it. Meanwhile, inside the workbook, any lookup comparing your formatted numbers against genuine text ZIPs fails, because the number 501 and the text 00501 are not equal. Custom formats are fine for printing; they are useless for data exchange.

The Excel 365 off switch

In October 2023 (Version 2309), Microsoft finally added an off switch to Excel for Microsoft 365. Go to File → Options → Data → Automatic Data Conversion and uncheck “Remove leading zeros and convert to a number.” While you are in there, consider unchecking the scientific-notation and date conversions too — the whole panel exists because of the CSV problems described on this site.

Two limits to keep in mind: the setting is per-machine, so a colleague's Excel will still strip zeros from the same file; and perpetual-license versions (Excel 2016, 2019, 2021) never received the option, which is why the Text-import habit above is still worth building.

Frequently asked questions

Can the zeros be recovered after Excel already saved the file?

Yes, fully. Unlike digits destroyed by scientific-notation rounding (see our scientific notation guide), leading zeros are recoverable because these codes have a known fixed width — a US ZIP is always 5 digits, a GTIN-8 is 8, a routing number is 9. Padding back to that width restores exactly what Excel removed.

I formatted the column as Text after opening the CSV. Why are the zeros still gone?

Because they were discarded the instant Excel parsed the file, before anything appeared on screen. Formatting as Text afterwards just stores the already-shortened 501 as text. The Text type must be assigned during import — Data → From Text/CSV with the column set to Text — for zeros to survive.

Why did only some values in my column lose their zeros?

Only values that begin with 0 are touched. 90210 sails through while 00501 becomes 501. Teams whose customers sit mostly in the West or South often never notice until the first order from Boston or Newark fails address validation.

Does Google Sheets remove leading zeros too?

By default, yes — same cause, same cure. When importing, uncheck Convert text to numbers, dates, and formulas in the File → Import dialog, or format the destination range as Plain text before pasting.