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

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.

RowA: what Sheets showsWhat it should be
2854008540
3213402134
49021090210
51000110001
650100501

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")
RowA: numberB: =TEXT(A2, "00000")C: =LEN(B2)
28540085405
32134021345
490210902105
510001100015
6501005015

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

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.

Duplicate ZIP codes or IDs hiding behind lost zeros? SheetDupes (disclosure: we make it) is a Google Sheets add-on for duplicate rows and messy contact data. Its Text match compares each cell as the text it holds, with extra spaces ignored, so a cell holding the text 08540 and a cell holding the number 8540 are two different values and are not paired. Restore the zeros first (Method 4), then run Preview on the column to see the real duplicates. Preview and Highlight are free on any size sheet; there is a 14-day free trial with no credit card, and writes remain free after the trial on sheets with up to 2,000 data rows during launch (through Jan 31, 2027; 500 after that). It only reads and writes the spreadsheet you have open, and your data is not sent to Loomwise. It is live on the Google Workspace Marketplace.
Get it on Google Workspace MarketplaceSee SheetDupes

Related guides