How to Keep Leading Zeros in Google Sheets: ZIP Codes, IDs and Phone Numbers When You Type, Paste or Import, and How to Fix Zeros Already Lost (2026)
You paste a list of ZIP codes, order numbers or employee IDs into Google Sheets and “08540” turns into “8540”. Sheets reads a value that looks like a number as a number, and a number has no leading zeros. This guide shows how to keep the zeros when you type, paste or import, how to display them on real numbers, and how to restore the ones that are already gone.
The short answer
- One value: type an apostrophe first, for example
'08540. - A whole column, before you paste or type: select it and choose Format › Number › Plain text.
- Keep real numbers but show the zeros: Format › Number › Custom number format, type
00000(one zero per digit), then Apply. - Zeros already lost:
=TEXT(A2, "00000")in a helper column returns08540as text. - CSV file: in File › Import, clear Convert text to numbers, dates, and formulas before importing.
Setting a column to Plain text after the zeros are gone does not bring them back, because the cell already holds the number.
The example
A list of five ZIP codes pasted into column A with the default format. The zeros were dropped from rows 2, 3 and 6.
| Row | A: what Sheets shows | What it should be |
|---|---|---|
| 2 | 8540 | 08540 |
| 3 | 2134 | 02134 |
| 4 | 90210 | 90210 |
| 5 | 10001 | 10001 |
| 6 | 501 | 00501 |
Method 1: type an apostrophe
For a handful of values, start the entry with an apostrophe: type '08540 and press Enter. A Google Product Expert explains in the Docs Editors Community that adding an apostrophe prefix always stores the value as a text string, that the apostrophe is not shown when you view the spreadsheet, and that it doesn’t affect downstream formulas. The same answer notes that Sheets stores numbers with the IEEE 754 standard, which leaves room for fewer than 16 digits of precision, so a very long ID is safest entered as text.
Method 2: format the column as Plain text first
For a column you are about to fill, select it, choose Format › Number › Plain text and then type or paste the values. Anything entered after that is kept as typed, so 08540 stays 08540. Order matters: format first and paste second. The same Product Expert answer warns that if you set Plain text after the fact, a value that has already been converted stays converted.
Method 3: a custom number format (real numbers, zeros shown)
If the values should stay numbers, for example IDs you sort or compare numerically, keep them as numbers and pad the display. Select the cells, choose Format › Number › Custom number format, type
00000
and click Apply. Google’s number formatting help describes 0 as “a digit in the number” where an insignificant 0 will appear, so a number with fewer digits than you have zeros is padded: 8540 displays as 08540 and 501 as 00501. Use as many zeros as the value has digits (seven for a seven-digit ID).
The cell still holds the number 8540. Only the display changes. If you need the zeros in the data itself, use Method 4.
Method 4: restore lost zeros with TEXT
Put this in B2 and fill it down to B6:
=TEXT(A2, "00000")
| Row | A: number | B: =TEXT(A2, "00000") | C: =LEN(B2) |
|---|---|---|---|
| 2 | 8540 | 08540 | 5 |
| 3 | 2134 | 02134 | 5 |
| 4 | 90210 | 90210 | 5 |
| 5 | 10001 | 10001 | 5 |
| 6 | 501 | 00501 | 5 |
Google’s TEXT help page explains that 0 forces display of zeros if a number has fewer digits than the format specifies, and the result is text. A value that already has five digits is unchanged, and a longer value keeps all its digits.
To fill a whole column without dragging, use an ARRAYFORMULA that leaves blank rows blank:
=ARRAYFORMULA(IF(A2:A="", "", TEXT(A2:A, "00000")))
An older trick pads with text instead:
=RIGHT("00000"&A2, 5)
It joins five zeros in front of the value and keeps the last five characters. That works for values of up to five digits, but it cuts a longer value down to its last five characters: a six-digit 123456 would become 23456. Prefer TEXT unless you know every value is short enough.
Replace the originals with the fixed values
To overwrite the originals with the restored text, first select column A and set Format › Number › Plain text, then copy B2:B6 and choose Edit › Paste special › Values only over A2:A6. (Google’s copy and paste help describes pasting values only.) Delete the helper column afterwards.
Method 5: import a CSV file without losing zeros
Choose File › Import, upload the file and, in the import dialog, clear Convert text to numbers, dates, and formulas before you click Import data. With the box cleared, a value such as 08540 is imported as text and keeps its zero. The trade-off is that real numbers and dates in the same file also come in as text, so convert those columns afterwards or import into a separate tab.
Find the cells that lost their zeros
If every value should be five characters, flag the short ones in a helper column:
=LEN(A2)<5
Rows 2, 3 and 6 of the example return TRUE. Run this check before you apply a custom number format: once a cell has the 00000 format, LEN counts the zeros that are shown, so a formatted 8540 returns 5 and is no longer flagged.
Why lookups and duplicate checks fail
A text 08540 and a number 8540 are different values. In a formula, ="08540"=8540 returns FALSE, so a lookup from a list of text ZIP codes into a list of numbers finds nothing, and a duplicate check treats the two cells as different. The fix is to make both lists the same type, for example text with Method 4, and then compare. For comparing two lists, see how to compare two columns or two sheets for duplicates.
Troubleshooting
- I set Plain text and the zeros didn’t come back. They were already dropped when the cells held numbers. Retype the values, or rebuild them with TEXT (Method 4).
- Only some rows have the problem. Check for text mixed with numbers in the same column with
=ISNUMBER(A2). TRUE means a real number; FALSE means text (zeros intact). - Ten-digit phone numbers lose a leading zero. The same fixes apply. For dashes, spaces and +1, see formatting phone numbers in Google Sheets.
FAQ
Why does Google Sheets remove the leading zero?
In a cell with the default Automatic format, Google Sheets reads a value such as 08540 as the number 8540, and a number has no leading zeros. To keep the zero you store the value as text (apostrophe or Plain text format) or keep the number and display it padded with a custom number format.
How do I type a number that starts with 0 in Google Sheets?
Type an apostrophe first, for example '08540. A Docs Editors Community Product Expert notes that the apostrophe is not shown when you view the sheet and doesn't affect downstream formulas.
How do I add leading zeros to a whole column that already lost them?
If every value should have the same length, either apply a custom number format of zeros (for five digits, 00000) to keep the numbers and display the zeros, or put =TEXT(A2, "00000") in a helper column to get text values with the zeros restored. Setting the column to Plain text afterwards does not bring the zeros back.
Does the TEXT function cut off values longer than the format?
No. Google’s TEXT help says 0 forces display of zeros when a number has fewer digits than the format specifies, so a longer value keeps all its digits. The alternative =RIGHT("00000"&A2, 5) does cut a longer value down to its last five characters, so use it only when every value has five digits or fewer.
How do I stop Google Sheets from dropping zeros when I import a CSV file?
Use File › Import, upload the file and clear the checkbox Convert text to numbers, dates, and formulas before importing. With it cleared, values that start with a zero are imported as text.
Why does my lookup fail when the ZIP code looks identical?
One side is probably the number 8540 and the other the text 08540. A text value never equals a number, so ="08540"=8540 is FALSE. Convert both lists to text, for example with TEXT(A2, "00000"), and then compare.
Get it on Google Workspace MarketplaceSee SheetDupes
Related guides
- How to Format Phone Numbers in Google Sheets: Strip Dashes and Spaces, Show (555) 010-1234, Handle +1 and Extensions, Then Find Duplicate Contacts (2026)
- How to Remove Extra Spaces in Google Sheets: Leading, Trailing and Double Spaces, Non-Breaking Spaces, Line Breaks and Why TRIM Isn’t Working (2026)
- How to Check if Email Addresses Are Valid in Google Sheets: ISEMAIL, Clean Up Spaces and Capitals, Flag Bad Emails and Find Duplicates (2026)
- How to Find and Remove Duplicates in Google Sheets: Highlight, Count, Delete and Keep the Original (2026)
- Duplicates That Don’t Match Exactly in Google Sheets: Case, Extra Spaces, Gmail Dots, Phone Formats and Typos (2026)
- How to Compare Two Columns or Two Sheets for Duplicates in Google Sheets (2026)
- How to Change Text Case in Google Sheets: UPPERCASE, lowercase, Proper Case Names, Sentence Case and Duplicates That Differ Only in Case (2026)