Force Excel to Keep Leading Zeros (zip codes, product codes, phone numbers)

Stop Excel from stripping leading zeros by formatting cells as Text or using a custom number mask. Includes quick apostrophe trick and how to restore zeros on existing data.

What the video covers

Preserve or restore leading zeros in Excel for new and existing columns of numeric-like codes such as zip codes, product IDs, and phone numbers.

Watch the video on YouTube

Step-by-step instructions

  1. Select the cells or column where you will enter codes
    Highlight the target range so the chosen format applies to all future entries in that area.
  2. Format cells as Text for literal preservation
    Open the Number Format dropdown on the Home ribbon and choose Text. Excel will treat every entry in the range as a string and keep any leading zeros exactly as typed.
  3. Use the apostrophe for single-cell entries
    Type a leading apostrophe before the number (for example '007). The apostrophe is hidden in display but forces Excel to store the entry as text, preserving zeros.
  4. Restore or pad existing numeric values with a custom mask
    For already-truncated numbers, open Format Cells (Ctrl+1), go to Number → Custom, and enter a format made of zeros matching the required length (for example 00000). This displays 123 as 00123 without changing the underlying value.
  5. Apply and verify
    Click OK to apply the format. Test by typing or selecting cells — values should display with leading zeros according to the Text format or the custom mask.
  6. Handle the green triangle warning
    Excel may flag 'Number Stored as Text' with a green triangle. You can safely ignore it, or click the warning icon and choose Ignore Error to clear it.

Watch the video

Video thumbnail for Force Excel to Keep Leading Zeros (zip codes, product codes, phone numbers) Play tutorial

Watch on YouTube

Why it matters

Excel treats entries that look like numbers as numeric values and removes non-significant leading zeros. Preserving zeros is essential for data integrity when codes must keep fixed width or exact characters.

Check your result

After applying the format or mask, entries like 00123 should display as 00123. If you used a custom format (e.g., 00000), entering 123 will display as 00123.

Troubleshooting

If zeros are already lost and you merely change Number to Text, values will still be numeric and zeros won't reappear. Use the Custom format (Ctrl+1 → Number → Custom) or reconstruct strings (prepend with an apostrophe or use a formula) to restore padding. Ignore the green "Number Stored as Text" triangle or use the error icon → Ignore Error to remove it.