Excel: How to Show Zeros Before a Number
In this article
Excel drops leading zeros because it treats any entry that looks like a number as a number, and numbers do not store leading zeros. To display them, you must either store the value as text or apply a custom number format that forces a fixed width. The quickest fix is to select the cells, press Ctrl+1 (Cmd+1 on Mac), choose Custom, and type a format such as 00000 — that shows five digits, padding with zeros. If the value must remain a true number for calculations, use the custom format; if it is an identifier such as a ZIP code or employee number, convert it to text instead.
What You'll Need
- Excel for Windows, Mac, or Excel for the web (the steps are the same unless noted).
- The cells or column containing the numbers you want to pad.
- A decision on whether the value must stay numeric (for math) or can become text (for IDs, codes, phone numbers).
Step-by-Step
- Select the cells. Click the column header or drag over the range. If you are formatting an entire column, click the letter at the top. Avoid selecting the header row if it contains words.
- Open Format Cells. Press
Ctrl+1(Windows) orCmd+1(Mac). You can also right-click the selection and choose Format Cells. The dialog opens on the Number tab. - Choose Custom. In the Category list, scroll down and click Custom. The Type box appears on the right.
- Enter a zero-padding format. In the Type box, type one zero for each total digit you want. For a five-digit code, type
00000. For a three-digit code, type000. The number of zeros sets the minimum width; numbers longer than that width are shown in full. - Confirm. Click OK. The cells now display leading zeros while the underlying value stays numeric, so formulas like SUM still work.
- For text-based IDs, use Text format instead. Select the cells, press
Ctrl+1, choose Text, and click OK. Then retype the values with the leading zeros. Note that any value already entered as a number will lose its zeros when converted; you must re-enter it. This method is best for ZIP codes, employee IDs, and phone numbers that are never used in arithmetic. - For data you are about to type, prefix with an apostrophe. Typing
'00123forces Excel to store the entry as text and display the zeros. The apostrophe is not shown in the cell. Use this for one-off entries, not whole columns. - If you are importing data, set the column type before import. In Power Query or the Text Import Wizard, set the column to Text rather than General so leading zeros are preserved from the source file.
Labels in the Format Cells dialog can differ slightly by Excel version, device, and region, but the Custom category and the zero-padding format are consistent across Windows, Mac, and the web app.
Common Mistakes
- Typing zeros into a General-formatted cell. Excel removes them the moment you press Enter. Format first, then type.
- Using Text format on cells that need math. Text values are ignored by SUM, AVERAGE, and most functions. Use the custom zero format instead.
- Forgetting that the custom format only changes display. The cell still contains 123, not 00123. If you copy the value to another program, the zeros may not carry over; use Paste Special > Values after converting to text if the zeros must travel.
- Applying too few zeros. A format of
000on the number 12345 shows 12345, not 0012345. Count the digits you need. - Converting an existing number column to Text without re-entering. The zeros will not appear retroactively. You must retype or use a formula such as
=TEXT(A1,"00000")in a helper column, then paste values.
Tips
- Use
=TEXT(A1,"00000")to generate a padded text version in a helper column without changing the original. Copy the helper column and Paste Special > Values if you want to replace the original. - For phone numbers, a custom format like
000-000-0000displays dashes and leading zeros together. - To pad with a different character, use a format like
00000only for zeros; Excel does not support arbitrary padding characters in number formats without custom code. - If you are pasting from another source, paste into a column already formatted as Text to preserve zeros from the clipboard.
- Remember that the custom format is stored per cell, so copying a formatted cell carries the format with it unless you paste values only.
Troubleshooting
- Zeros still disappear after formatting. Check that the cell is not formatted as General or Number after you applied the custom format. Reopen Format Cells and confirm Custom is selected with the zero pattern.
- The custom format shows more zeros than expected. The format sets a minimum width; if the number is shorter, it pads. If it is longer, it shows all digits. Reduce the number of zeros if you want a fixed width shorter than the value.
- Formulas return errors after converting to Text. Text values cannot be summed. Convert back to numbers or use the custom format approach instead.
- Leading zeros vanish when opening a CSV. Excel interprets CSV columns automatically. Use Data > From Text/CSV and set the column to Text in the preview before loading.
- The apostrophe shows in the cell. You likely typed a different character, such as a backtick. Use the straight apostrophe (').
Frequently Asked Questions
Why does Excel remove leading zeros?
Excel treats entries that look like numbers as numeric values, and numbers do not store leading zeros. The zeros are not hidden; they are not part of the value.
Can I keep leading zeros and still use the numbers in calculations?
Yes, use a custom number format with zeros. The cell displays the padded value but stores the original number, so formulas work normally.
What is the difference between Text format and Custom format for zeros?
Text format stores the zeros as part of the value and prevents calculations. Custom format only changes how the number is displayed; the underlying value is unchanged.
How do I add leading zeros to a whole column at once?
Select the column, press Ctrl+1, choose Custom, and enter the zero pattern. All selected cells update immediately.
Will leading zeros survive if I copy the cells to another program?
Only if the cells are stored as text. Custom-formatted numbers copy as their underlying value, so the zeros may be lost. Convert to text first if the zeros must travel.
Can I use a formula to pad with zeros?
Yes, the TEXT function does this: =TEXT(A1,"00000") returns a text string with leading zeros.