Barcode check digit errors in a CSV: find and fix
A store or marketplace rejects some barcodes in your product CSV, or the free CSV check reports "Barcode check digit does not add up". The barcode has a normal length, but its last digit does not match the digits before it. The barcodes in this post are made up; they do not belong to real products.
What a check digit is. A GTIN is the number printed under a product barcode: 8 digits (EAN-8), 12 (UPC-A), 13 (EAN-13) or 14 (GTIN-14). Its last digit is the check digit, calculated from all the digits before it. One wrong digit always makes it stop matching, and so do most swaps of two neighbouring digits. A matching check digit only shows that the number is well formed; it does not prove the code belongs to your product.
Why it happens. A digit was mistyped, or two digits were swapped. A digit other than a leading zero was cut off: a 13-digit code that loses one digit still has an accepted length of 12, so it is usually read as a 12-digit code whose last digit does not match. A CSV that held 9.52E+12 was turned back into a full number, which gives 9520000000000: the lost digits come back as zeros, and the check digit usually no longer matches. The check digit was typed by hand instead of calculated.
Lost leading zeros are a different problem. Zeros add nothing to the calculation, so 09520000123451 and 9520000123451 both add up. A code that lost its leading zeros either still passes or gets a length the check does not accept; for that, see "Why SKUs lose leading zeros in CSV files". A value shown in E form, such as 1.23E+12, is covered in "Barcodes shown as 1.23E+12 in a CSV: find and fix".
Check a 13-digit barcode by hand. Take the made-up code 9520000123451. 1. Take the first twelve digits: 952000012345. 2. Add the digits in the odd positions (first, third, fifth and so on): 9 + 2 + 0 + 0 + 2 + 4 = 17. 3. Add the digits in the even positions: 5 + 0 + 0 + 1 + 3 + 5 = 14, then multiply by 3: 42. 4. Add both results: 17 + 42 = 59. 5. The check digit is what you add to reach the next multiple of 10: 60 - 59 = 1. The code ends in 1, so it adds up. The same code ending in 2, 9520000123452, fails, and so does 9520000123415, where the last two digits are swapped.
Codes of 8, 12 and 14 digits follow the same rule, counted from the right: starting with the digit just left of the check digit, multiply every other digit by 3 and the rest by 1, add them up, and the check digit brings the total to the next multiple of 10. The free check page also shows a spreadsheet formula for a 13-digit code.
Fix it. 1. Work on a copy of the file. 2. Find the product's barcode on the packaging, the supplier's label or list, or your product records, and copy the full code from there. 3. Set the barcode column to text before you paste, so the spreadsheet keeps every digit, including leading zeros. 4. Do not change the last digit just to make the code pass. If a digit before it is wrong, a code that passes would still point to a different product. 5. If you cannot confirm the number, leave the cell empty rather than guessing, if your store allows products without a barcode. 6. Save the file as CSV again.
Recheck. Open the saved CSV in a plain text editor and confirm that each barcode you fixed has all its digits, including any leading zeros. Then run the free CSV check again. It reads the barcode from a column named gtin, barcode, variant barcode, ean, upc or barkod (capital letters do not matter); a column with any other name, such as "barcode number" or "ean13", is not checked, and if a file has two such columns only the first one is. It removes spaces inside a code and accepts 8, 12, 13 or 14 digits. A code of another length, or with other characters, is reported as "Barcode has the wrong number of digits"; a code of an accepted length whose last digit does not match is reported as "Barcode check digit does not add up". Empty barcode cells are skipped, and only the first 20 data rows are checked. A clean result shows the codes are well formed, not that they are the right ones, so compare a few rows with the packaging.
sku,title,price,barcode
M1,Blue mug,9.50,9520000123451
M2,Red mug,9.50,9520000123452
M3,Green mug,9.50,9520000123415Check your CSV on heloft.com (se abre en una pestaña nueva)
De dónde salen las cifras
- HQ CEO chain draft, 27 September 2026, accepted by a separate quality agent; made-up barcodes only, no customer file
- GS1 General Specifications, check digit calculation for GTIN-8, GTIN-12, GTIN-13 and GTIN-14 (weights 3 and 1 from the right, modulo 10); the worked example was recalculated by the dev team
- Free CSV check behaviour (heloft.com/m01): barcode columns named gtin, barcode, variant barcode, ean, upc or barkod; 8, 12, 13 or 14 digits accepted, other lengths flagged as the wrong number of digits, a wrong last digit flagged as a check digit that does not add up; empty cells skipped; the first 20 data rows are checked (local run with synthetic files, 27 September 2026)