🌐 English

Home › Guides

Why Leading Zeros Disappear in Excel and How to Keep Them

You open a CSV and the zip code 01234 has become 1234, or a phone number lost its first zero. The file is not broken: the spreadsheet simply decided those values were numbers. Here is why it happens and how to protect your data.

Why the zero vanishes

A CSV file is plain text. It carries no information about whether a column holds numbers or words, so the spreadsheet program guesses when it opens the file. A value such as 0012 looks like a number, and in a number the leading zeros carry no meaning, so the program stores it as 12.

The original file may still contain 0012, but the screen shows 12, and if you save, the change becomes permanent. The most common accident is opening a file just to look and then pressing save, which quietly rewrites every affected cell.

Habits that cause trouble

Double-clicking a CSV is the riskiest way to open it. The program applies the General format to every column and converts values on the fly. Changing the column format to Text afterwards does not bring back zeros that were already dropped.

Re-padding values with a formula is only a patch. If your codes have different lengths, a formula that forces a fixed length will quietly create wrong values that look right.

Importing without losing zeros

The import feature (often called From Text/CSV under the Data tab) lets you choose the type of each column before the data lands in the sheet. Select the columns that carry leading zeros, set their type to Text, then load. The values arrive exactly as written.

If you are typing new values into an open sheet, set the cell format to Text first. Anything you type afterwards, including zeros at the start, will be kept.

Build an xlsx from the start

If the person receiving your file is likely to double-click a CSV, hand over an xlsx instead. An xlsx file stores whether each cell is text or a number, so Excel has nothing to guess when it opens it.

The CSV to Excel tool on this site converts a CSV into an xlsx right in your browser. Values with leading zeros are written as text cells, so they survive when the file is opened. Nothing is uploaded to a server.

A quick verification checklist

After you finish, confirm the values were really preserved. If the file will be uploaded into another system, one careless save can corrupt thousands of codes at once.

Walk through the checks below in order. If you find a problem, do not save; start again from the original file, which is usually faster than repairing.