How to Keep 0s in Excel: Leading Zeros, Zero Values and CSVs
Stop Excel from dropping leading zeros in ZIP codes, IDs and CSV imports, restore zeros already lost, and make zero values show up again on your worksheet.
To keep 0s in Excel, format the cells as Text before you type or paste (or start the entry with an apostrophe, like '01234), or apply a custom number format such as 00000 so Excel pads numbers with zeros. If your data comes from a CSV file, import it through Data > From Text/CSV and set the column to Text, because simply opening the file lets Excel strip the zeros first.
Which method is right depends on whether the value is really a code (ZIP code, product ID, phone number) or a number you need to calculate with. The sections below walk through each option, plus the other common meaning of “keep 0s”: making zero values visible instead of blank.
Why Excel removes leading zeros
Excel sees 00742 and decides it is the number 742. Numbers don’t carry leading zeros, so they disappear. Microsoft also notes that Excel stores numbers with 15 digits of precision, so long codes such as credit card or account numbers can be truncated or shown in scientific notation (Microsoft Support).
The practical rule: if you will never add, average or sort the value numerically, store it as text. If it is a genuine number that should just look padded, use a custom format.
Quick comparison of the options
| Method | Keeps the real zeros? | Works for 16+ digits? | Best for |
|---|---|---|---|
| Format cells as Text first | Yes (stored as text) | Yes | IDs, ZIP codes, phone numbers you type in |
Apostrophe prefix ('0123) | Yes (stored as text) | Yes | One-off entries |
Custom format (00000) | No, display only | No (fewer than 16 digits) | Numbers that must stay numeric |
TEXT formula | Yes (result is text) | Depends on source value | Fixing data that already lost its zeros |
| Import CSV as Text (Power Query) | Yes | Yes | CSV and text files |
| Turn off automatic data conversion | Yes | Yes | Stopping the conversion everywhere, if your version has it |
Method 1: Format cells as Text before entering data
This is the simplest fix for codes you type or paste in.
- Select the column or cells.
- Right-click and choose Format Cells (or press Ctrl+1).
- On the Number tab, choose Text and click OK.
- Now type or paste your values.
00742stays00742.
The order matters: formatting cells as Text after the zeros are gone won’t bring them back.
The apostrophe shortcut
For an occasional entry, type an apostrophe first: '00742. The apostrophe doesn’t show in the cell, and Excel stores the value as text with its zeros intact. This approach is widely recommended in third-party guides and is handy when you don’t want to reformat a whole column.
Method 2: Use a custom number format
If the values need to stay numeric (for example, so formulas still treat them as numbers) but should always display a fixed number of digits, use a custom format.
- Select the cells.
- Press Ctrl+1 to open Format Cells.
- Choose Custom in the Category list.
- In the Type box, enter one zero per digit you want, for example
00000for a five-digit ZIP code or0000for a four-digit code. - Click OK.
Microsoft also mentions a built-in Special format as an alternative to a custom one.
Keep two limits in mind, both from Microsoft’s guidance:
- It only works for number codes with fewer than 16 digits.
- It changes the display, not the stored value. Microsoft recommends this route only when the workbook isn’t used as a data source by other programs. If you export to CSV or another system reads the file, the zeros won’t be in the underlying data.
Method 3: Restore zeros that are already gone with TEXT
If a column of ZIP codes has already been converted (so 00742 now reads 742), you can rebuild the padding in a helper column:
=TEXT(A2,"00000")
This returns text padded to five digits. Change the number of zeros to match the length you need. Once it looks right, you can copy the helper column and use Paste Special > Values to replace the originals.
This only works when you know the correct length. If the codes had different lengths, or were longer than 15 digits and got truncated, re-import the original source file instead.
Method 4: Import CSV and text files without losing zeros
Double-clicking a CSV opens it with Excel’s default conversions, which is where most lost zeros come from. Importing it through Power Query lets you set the column type first. Based on Microsoft’s steps:
- Open a blank workbook and go to Data > From Text/CSV.
- Select your file and click Import.
- In the preview, click Transform Data to open the Power Query Editor.
- Click the header of each column that should keep its zeros.
- Go to Home > Transform > Data Type and choose Text.
- If asked, choose Replace current.
- Click Close & Load to bring the data into your sheet.
Because the column is text from the start, the zeros are never stripped. Note that the automatic data conversion settings described next don’t apply to data loaded through Power Query, so set the column type there.
Method 5: Turn off automatic data conversion
Microsoft added options that let you stop Excel from converting certain entries, including “Remove leading zeros from numerical text and convert to a number” and an option to stop truncating long numbers to 15 digits (Microsoft 365 Insider Blog). Unticking the leading-zeros option keeps ZIP codes and similar values intact when you type, paste or open text files (Excel Campus).
Where to find it:
- Windows: File > Options, then look for Automatic Data Conversion. Microsoft’s support page lists it under the Data section, while the Insider blog post places it under Advanced, so check both depending on your build (Microsoft Support).
- Mac: Excel > Preferences > Edit, then Automatic Data Conversion.
According to TechRepublic, unticking the top option, which enables all default conversions when entering, pasting or loading text, turns them all off at once.
A few caveats:
- The setting changes how Excel behaves going forward; it doesn’t repair data already converted.
- It isn’t available in every version. Some users with older perpetual licenses report not seeing it, and one report suggests it was moved or removed in some Microsoft 365 builds. As of November 2026 we couldn’t confirm which builds include it, so if you don’t see it, use Methods 1 to 4.
- Other people opening your file in their own Excel may have the default conversions switched on.
If your “0s” are zero values showing as blanks
Some people searching this mean a different problem: cells that contain 0 appear empty. That is usually a worksheet display setting (Microsoft Support).
- Go to File > Options > Advanced.
- Scroll to Display options for this worksheet and pick the sheet.
- Tick Show a zero in cells that have zero value.
- Click OK.
This setting applies to the whole worksheet. If zeros are still hidden in specific cells, check their custom number format (a format with an empty third section, such as 0.00;-0.00;;@, hides zeros) or any conditional formatting that colors zeros to match the background.
Which method should you use?
- Typing codes by hand: format the column as Text first.
- Opening a CSV: import with Data > From Text/CSV and set the column to Text.
- Numbers that must stay numeric: custom format like
00000, as long as they’re under 16 digits. - Zeros already lost:
=TEXT(A2,"00000"), or re-import the original file. - Want Excel to stop doing this everywhere: look for Automatic Data Conversion in Options, if your version offers it.
Menu names and option locations can shift between Excel updates, so if a path above doesn’t match your screen, search the ribbon’s search box for the option name.
Free apps worth trying
SponsoredSponsored links. Installing through them can earn us a commission, at no cost to you. Apps are free to download; some offer optional in-app purchases.
Frequently asked questions
Why does Excel delete the 0 at the start of my number? +
Excel treats anything that looks like a number as a number, and numbers don't have leading zeros, so 01234 becomes 1234. Storing the value as text, or applying a custom number format, tells Excel to keep the zeros.
Can I get back leading zeros Excel already removed? +
Not by changing the cell format alone; Microsoft notes a custom format won't restore zeros removed before it was applied. You can rebuild them with a formula such as =TEXT(A2,"00000") if you know how many digits the value should have, or re-import the original file with the column set to Text.
Will a custom format like 00000 keep the zeros when I save as CSV? +
A custom format only changes how the number is displayed; the stored value has no leading zeros. If another program will read the data, Microsoft recommends storing it as text instead, for example by importing the column as Text.
My zeros show as blank cells. How do I make them appear? +
That is usually the sheet-wide display setting. Go to File > Options > Advanced, find Display options for this worksheet, and tick Show a zero in cells that have zero value.
Sources
- Keeping leading zeros and large numbers (Microsoft Support) (support.microsoft.com)
- Set automatic data conversions (Microsoft Support) (support.microsoft.com)
- Control data conversions in Excel for Windows and Mac (Microsoft 365 Insider Blog) (techcommunity.microsoft.com)
- How to Control Data Conversions in Excel for Windows and Mac (TechRepublic) (techrepublic.com)
- Display or hide zero values (Microsoft Support) (support.microsoft.com)
- New Excel Feature: Automatic Data Conversion for Numbers (Excel Campus) (excelcampus.com)