Excel removes leading zeros because it treats any number you type as a numeric value, and leading zeros have no mathematical meaning. To stop it, format the cells as Text before you type, or enter the value with an apostrophe in front (like '0123), or use a custom number format that displays a fixed number of digits. The cause and the fix depend on whether you are typing new data, importing a CSV, or working with a column that already lost its zeros.
What You'll Need
- Excel for Windows, Mac, or the web (steps are nearly identical; labels can differ slightly by version and region).
- The file or column where zeros are disappearing.
- For imported files: the original CSV or text file, so you can re-import with the correct column type.
Step-by-Step
- Decide whether the value is a number or an identifier. ZIP codes, phone numbers, employee IDs, product codes, and account numbers are identifiers, not quantities. You never add them up, so they should be stored as text. If you do need to calculate with the value, keep it numeric and use a display format instead (Step 4).
- For new typing, format the cells as Text first. Select the column or range, right-click, choose Format Cells, open the Number tab, pick Text, and click OK. Anything you type afterward keeps its leading zeros. Formatting after the fact does not bring zeros back, because Excel already discarded them.
- Use the apostrophe trick for one-off entries. Type an apostrophe before the value, for example
'00456. Excel stores it as text and hides the apostrophe in the cell. This is quick for a handful of cells but tedious for a whole column. - For numeric values that must show zeros, apply a custom format. Select the cells, open Format Cells > Number > Custom, and enter a format with the right number of zeros, such as
00000for five digits. The stored value stays a number, so formulas still work, but the display pads with leading zeros. A format of00000shows 123 as 00123. - For CSV and text imports, use the import wizard instead of double-clicking the file. In Excel, go to Data > From Text/CSV (or Get Data), select the file, and in the preview choose Transform Data. Set the ZIP or ID column's data type to Text before loading. If you just open a CSV by double-clicking, Excel guesses the type and strips zeros.
- To recover zeros in a column that already lost them, rebuild it with a formula. If every value should be a fixed width, use
=TEXT(A2,"00000")in a helper column, then copy the results and paste them back as values. For variable widths,=REPT("0",5-LEN(A2))&A2pads to five characters. Check a sample of results before replacing the original data. - Save the workbook in a format that keeps text. Standard .xlsx preserves text-formatted cells. If you export back to CSV, open the CSV in a text editor or re-import it with the column set to Text, because a plain CSV has no formatting and the next program may strip zeros again.
Common Mistakes
- Formatting as Text after typing. Changing the format later does not restore zeros that were already dropped; the underlying value is gone. Re-enter or rebuild the data.
- Using a custom format on text cells. Number formats only affect numeric cells. If the cell is already Text, a
00000format does nothing. - Double-clicking CSV files. This lets Excel auto-detect types and is the most common reason imported IDs lose zeros. Use the import wizard instead.
- Pasting from another app. Pasting plain numbers into General-formatted cells strips zeros. Paste into pre-formatted Text cells or use Paste Special > Text.
- Assuming the zeros are gone everywhere. The value in the formula bar may still be correct while the display is rounded or padded. Click a cell and check the formula bar before rebuilding anything.
Tips
- Format entire columns as Text before pasting a list of IDs, so you do not have to fix rows one at a time.
- Keep a separate numeric copy of any value you need to sort or calculate with, and a text copy for display.
- For ZIP codes, a custom format of
00000handles five-digit codes but not ZIP+4; use Text for those. - When sharing a workbook, tell recipients which columns are text so they do not retype them as numbers.
- Use Data > Text to Columns to convert an existing column to Text in place if the values are still intact.
Troubleshooting
Zeros still disappear after formatting as Text. Check that you formatted the cells before typing. If the values are already numeric, the zeros are gone from the stored value; rebuild them with the TEXT formula in Step 6.
The custom format shows the wrong number of zeros. Count the digits in your longest value and use that many zeros in the format code. A format shorter than the value does not truncate it, but it will not pad correctly.
Imported CSV still loses zeros. Re-import using Data > From Text/CSV and set the column type to Text in the preview. If the preview itself shows the zeros missing, the source file may already have lost them; open it in a plain text editor to confirm.
Formulas return errors after converting to Text. Text values cannot be summed or averaged. Keep a numeric helper column for calculations, or convert back with VALUE() where needed.
Zeros reappear as numbers after saving to CSV. CSV stores no formatting. Keep the master copy in .xlsx and treat the CSV as an export only.
Frequently Asked Questions
Why does Excel remove leading zeros?
Excel treats typed digits as numbers, and leading zeros carry no numeric value, so they are dropped. Formatting the cell as Text or using a custom number format prevents this.
Can I get the zeros back after they are gone?
Not automatically. The original digits were discarded. Rebuild the column with a TEXT formula or re-enter the values into cells formatted as Text.
Does the apostrophe trick work on Mac and Excel for the web?
Yes. Typing an apostrophe before a value stores it as text in Excel for Windows, Mac, and the web. The apostrophe is hidden in the cell but visible in the formula bar.
Will formatting as Text break my calculations?
Yes, for those cells. Text values are ignored by SUM and AVERAGE. Use a custom number format if you need both leading zeros and calculations.
How do I stop zeros disappearing when I open a CSV?
Do not double-click the file. Use Data > From Text/CSV, then set the affected column to Text in the preview before loading.
Can I format a whole column to always show five digits?
Yes. Select the column, open Format Cells > Number > Custom, and enter 00000. Every number in that column will display with leading zeros to five digits.