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.
Zip codes: 01234 becomes 1234
Phone numbers written without separators: 01012345678 becomes 1012345678
Product or employee codes: 000451 becomes 451, and very long numbers may turn into scientific notation such as 1.23E+15
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.
Opening and saving changes the original, so always work on a copy
Switching to Text format after the fact cannot restore removed zeros
Typing an apostrophe before each value may leave an extra visible character in the saved file
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.
Data tab, then From Text/CSV, then set the column type to Text before loading
For new input, apply Text format to the cells first and type afterwards
Treat every number you never calculate with (zip, phone, account, ID) as text
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.
If the recipient uses Excel, send xlsx instead of CSV
After converting, check a few cells: the first row, rows starting with 0, and very long numbers
Keep the original CSV untouched and save the converted file under a new name
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.
Check lengths: every value in a code column should have the same number of characters
Sort the column: text aligns to the left, numbers to the right
Open the file in a plain text editor to see whether the zeros are still inside
Make sure long numbers such as card or account numbers are not shown in scientific notation