PixelTools
All articles
Guides4 min readby the PixelTools team

Why Excel Drops the Zero on Your UPC Barcode

UPC missing its leading zero in Excel or CSV? See why it happens, how a generator can add a wrong check digit, and how to restore and verify the code.

Why Excel drops the zero

Excel drops the zero because it reads a barcode as a number, and a number has no use for a leading zero. Type 012345678905 into a General-format cell and you get 12345678905. Nothing is wrong with the barcode. The cell just turned text into a quantity. It happens when you paste, when you type, and when you open a CSV by double-clicking it. Once the cell is a number, the zero is gone from what Excel stores, not just from what it displays. Barcodes are identifiers, like phone numbers or ZIP codes. They are never added or averaged, so they belong in a text column. The fix is to set the column to Text before the data goes in, not after.

The trap: a 12-digit UPC becomes a valid-looking 11-digit one

A UPC-A has 12 digits, and the last one is a check digit. Lose the leading zero and you have 11 digits, which is exactly the length of a UPC without its check digit. Many generators see 11 digits and helpfully add a check digit, so nothing errors. Take 012345678905. After Excel it reads 12345678905. Our barcode generator, like the JsBarcode library under it, appends a computed check digit and draws 123456789050. That is a clean, scannable, wrong barcode: the digits shifted one place, and it no longer matches the product. Fed through a generator that accepts 11 digits, the damage is silent.

How to spot a stripped zero

Count the digits first. A UPC-A is always 12, an EAN-13 is always 13, an EAN-8 is always 8, and an ITF-14 is always 14. An 11-digit UPC in a column of 12-digit ones is almost certainly a victim. Sort the column by length, or put =LEN(A2) next to it and filter for anything short. Also watch for scientific notation: Excel's General format shows numbers of 12 or more digits as something like 1.23457E+11, and it keeps only 15 significant digits, so a 16-digit code is permanently rounded. If you see an E+ in a code, the original digits may already be lost.

Restore the zero and prove it is right

Pad the short value back to full length, then check the last digit. In Excel, =TEXT(A2,"000000000000") pads a UPC-A to 12 digits (use 13 zeros for EAN-13). Then verify the check digit: weight the digits 3,1,3,1 from the right-hand side of the first 11, sum them, and the check digit tops the sum up to the next multiple of 10. Padded 012345678905 passes. A wrong padding passes only about one time in ten, so a pass is strong evidence but not proof. Confirm against the product packaging or a supplier sheet when the code matters. Do not pad blindly across a whole column without checking.

Stop it happening again

Format the column as Text before you paste or type. For a CSV, do not double-click it. In Excel, use Data, then From Text/CSV, and set the barcode column to Text in the preview. The CSV file itself still contains the zeros, and only Excel's view of it loses them, so check the raw file in a text editor before assuming it is damaged. Never save over the original from Excel's view. In Google Sheets, format the column as Plain text first. Marketplaces and POS imports often drop zeros the same way, so keep a text-format master copy of your product codes.

Check the repaired code

After restoring the codes, confirm each one by entering all 12 digits into the barcode generator rather than 11. With 12 digits it verifies the check digit instead of making one up, and tells you if it is wrong. With 11 it adds a check digit, which is what you want only for a code that never had one. Then scan the result with the barcode scanner to confirm it reads back as the same digits you started with. A scan that returns a different number than your spreadsheet means the codes shifted somewhere upstream.

Frequently asked questions

Try it on PixelTools — free, no upload needed