Leading zeros disappear in Google Sheets (00123 becomes 123) — fix for ids and ZIP codes
Updated
You type 00123 and the cell shows 123. There is no error triangle. Sheets decided the value was a number, and leading zeros are not part of a number. ZIP codes, employee ids, account numbers, and short SKUs get shortened the same way when you type them, paste them, or SPLIT them out of a longer string. A custom number format can paint the zeros back. It does not change the stored value, and a lookup against the original text code can still miss.
This page is short codes whose zeros were dropped on entry. A long id that became 1.23E+15 and lost digits is CSV scientific notation. An imported apostrophe that is a real character, so VALUE is #VALUE!, is CSV leading apostrophe. Keep the Google Sheets UI in English.
Recreate it on a blank sheet
Section titled “Recreate it on a blank sheet”- Open a blank spreadsheet. In A1 type
typed. In A2 type00123and press Enter. A2 displays123, usually right-aligned. The formula bar shows123. There is no apostrophe and no triangle. Leave A2 as that number.
Paste does the same. In A4 type pasted. Copy the five characters 00123 from a text editor (or from a cell that is already text). Select A5 and paste. A5 is 123 again if the destination format is Automatic.
SPLIT drops zeros too. In A7 type split_src. In B7 type 00123,00124 as one text string (start with an apostrophe if Sheets tries to parse it). In A8 type split. In B8 enter =SPLIT(B7,","). B8 and C8 display 123 and 124. The leading zeros in the source string did not survive the split. Leave B8 as that spill.
A format only changes the paint. Select A2. Format → Number → Custom number format, type 00000, Apply. A2 now displays 00123. The formula bar is still 123. ISNUMBER(A2) is TRUE. ISTEXT(A2) is FALSE. On 2026-11-27 in English Sheets (Locale United States), =LEN(A2) returns 5, because LEN uses the formatted display. =LEN(A2*1) returns 3, which is the stored number. TO_TEXT(A2) is 00123. Leave this format on A2 so the next contrast is visible.
Text stored correctly, as control. In C1 type text_id. In C2 type an apostrophe, then 00123. C2 displays 00123, left-aligned. The formula bar shows '00123 (the prefix apostrophe remains visible in the formula bar; it is still a prefix, not part of the stored value). ISTEXT(C2) is TRUE. LEN(C2) is 5. Leave C2 as the control.
A lookup that misses after a format fix. In E1 type lookup. In E2 type an apostrophe, then 00123 (text, the form an imported list often has). In F1 type against_number. In F2 enter =VLOOKUP(E2,A2:A2,1,FALSE). Even with A2 displaying 00123, F2 is #N/A. Text 00123 is not the number 123. In F4 type against_text. In F5 enter =VLOOKUP(E2,C2:C2,1,FALSE). F5 is 00123. Leave F2 broken.
What is actually wrong
Section titled “What is actually wrong”- Anything Sheets can parse as a number is stored as a number, unless you stop it first. Leading zeros are formatting, not part of the value, so they disappear.
- Format → Number → Custom number format
00000(or a ZIP format) only changes the display. Exact-match lookups still see the number123, so text00123misses.LENis not a reliable check of the stored value: on 2026-11-27,LEN(A2)on this formatted cell returned 5 (the display), whileLEN(A2*1)returned 3. TEXT(A2,"00000")builds a new text value00123. That is the right direction for a helper column. It cannot invent zeros for a 15-digit id whose low digits were already rounded off: CSV scientific notation.SPLIT,TEXT TO COLUMNS, and many imports go through the same number parser. Formatting the destination as Plain text before the paste or the split is what preserves the zeros.- A typed apostrophe prefix (
'00123) is the standard way to enter text. The prefix is not part of the stored value (ISTEXTis TRUE,LENis 5), but the formula bar may still show the leading apostrophe, as it did on 2026-11-27. A CSV that leaves a visible apostrophe inside the cell is the other page: CSV leading apostrophe.
This is not formula shows as text. Plain text is useful here, and harmful there, because here you want text. This is not CSV text vs number as the main story, although a leftover type split will also break VLOOKUP: VLOOKUP #N/A.
Leave A2 in the 00000 display format, and leave F2 as #N/A.
For new entry, make the column text first. Select the column. Format → Number → Plain text. Then type or paste 00123. The zeros stay, LEN is 5, ISTEXT is TRUE. For a single cell, the apostrophe prefix is enough.
For numbers already stored, add a helper: =TEXT(A2,"00000") in D2. D2 is the text 00123. Look up against D2, not against A2. A five-digit ZIP uses "00000"; a nine-digit ZIP-plus-4 needs a different pattern and usually should have arrived as text anyway.
For SPLIT, split into a Plain text range, or wrap the pieces: =TO_TEXT(SPLIT(B7,",")) will not put the zeros back if SPLIT already returned numbers. Preserve text upstream ('00123,00124 stored as text is not enough by itself once SPLIT parses each piece). A reliable pattern is to keep a leading apostrophe or a non-numeric prefix in the source, or to use a text-extracting formula such as =REGEXEXTRACT(B7,"^0*\d+") on each piece after splitting as text. If SPLIT has already dropped the zeros, you can only re-pad to a known width with TEXT.
Match types in lookups. If the official id is text 00123, the table column must be text 00123. A 00000 format on a number is not a match. See VLOOKUP #N/A.
If the code is 16 digits and already shows scientific notation, stop and use CSV scientific notation. The low digits are gone. Padding with TEXT will not bring them back.