Food Barcodes Explained: UPC vs EAN, What the Digits Mean and How to Look One Up
7 min read
Almost every packaged food carries a barcode, and the number under it is a global product ID. It does not encode calories or ingredients directly. Instead it is a key you can use to look those details up in a database. This guide explains how food barcodes work, what each part of the number means, how to check that a number is valid, and how to get reliable nutrition information from one, whether you are a shopper or building an app.
What a food barcode actually contains
A retail barcode is a Global Trade Item Number (GTIN) printed in a machine-readable pattern of bars and spaces. The number identifies one specific product variant: a 330ml can of Coca-Cola has a different number from a 500ml bottle, and a multipack has its own number again. Flavors, sizes and pack counts each get their own GTIN.
The barcode itself carries no price, nutrition, ingredients or expiry date. Shops link the number to a price in their own systems, and nutrition apps link it to a product record. That is why the same barcode can show different prices in different stores, and why a brand-new product may not appear in any lookup yet.
Barcodes are issued through GS1, a not-for-profit standards body with member organizations in over 100 countries. Manufacturers license a company prefix from their local GS1 office and assign product numbers under it. Because each company prefix is unique, two manufacturers should never end up with the same product number.
UPC vs EAN: the two formats you will see
UPC-A has 12 digits and is the standard format in the United States and Canada. EAN-13 has 13 digits and is used almost everywhere else. The two are compatible: a UPC-A code is simply an EAN-13 with a leading zero, so 012000001291 and 0012000001291 refer to the same product. Modern checkout scanners read both.
Small packs such as chewing gum or single chocolate bars often use shorter versions: UPC-E (a compressed 8-digit UPC) or EAN-8. These exist purely to fit on small labels. A UPC-E code expands back to a full 12-digit UPC-A, and many lookup tools do this automatically.
Some products carry a GTIN-14 on outer cartons. Those identify a case of products for warehouses and are rarely useful for nutrition lookups; use the barcode on the individual item instead.
What each part of the number means
The first two or three digits of an EAN-13 are the GS1 prefix. They show which national GS1 office issued the company prefix, not where the food was made. For example, 001–019, 030–039 and 060–139 are used by GS1 US, 30–37 by GS1 France, 400–440 by GS1 Germany, 50 by GS1 UK, 54 by GS1 Belgium and Luxembourg, 690–699 by GS1 China, 750 by GS1 Mexico and 84 by GS1 Spain. A product with a 54 prefix can be manufactured in any country.
Some ranges are reserved for special uses. EAN-13 codes starting with 02 or 20–29 are for restricted, in-store use; in a 12-digit UPC-A these appear as codes starting with 2. Supermarkets use them for loose produce, deli counters and variable-weight items like meat, where the barcode often encodes the weight or price. Codes starting 04 are also reserved for a company's internal use. None of these will work in a nutrition lookup because they mean something different in every store. Codes starting 978 or 979 are book numbers (ISBNs).
After the GS1 prefix comes the rest of the manufacturer's company prefix, then the item reference the manufacturer chose for that product. The company prefix varies in length, so you cannot always tell from the number alone where the company part ends and the product part begins. The final digit is always the check digit.
Coca-Cola barcodes and other big brands
Large brands often have different barcodes in different countries because each market's product is packed, labeled and registered separately. A common example is 5449000000996, which is widely listed for a 330ml can of Coca-Cola Classic. Its 54 prefix comes from GS1 Belgium and Luxembourg, where Coca-Cola registered numbers for many European products.
If you are looking for the codigo de barras of a Coca-Cola product, or any other brand, the reliable source is the package in your hand. The number for a can in Mexico, a bottle in Spain and a can in the US will not be the same, and the recipe and nutrition panel may differ between countries as well.
How the check digit works
The last digit lets scanners catch typos and misreads. For an EAN-13, multiply the first 12 digits alternately by 1 and 3 starting from the left, add the results, and the check digit is whatever brings the total up to the next multiple of 10. If the total is already a multiple of 10, the check digit is 0.
Worked example with 5449000000996: 5×1 + 4×3 + 4×1 + 9×3 + 0 + 0 + 0 + 0 + 0 + 0 + 9×1 + 9×3 = 84. The next multiple of 10 is 90, so the check digit is 6, which matches the final digit.
For a 12-digit UPC-A the weights start with 3 instead: multiply the 1st, 3rd, 5th, 7th, 9th and 11th digits by 3 and the others by 1. For 012000001291 that gives (0+2+0+0+1+9)×3 + (1+0+0+0+2) = 36 + 3 = 39, so the check digit is 1. Adding a leading zero to make it an EAN-13 shifts every digit by one place, which is why the same check digit still works.
If you type a barcode by hand and the lookup says it is invalid, the check digit is the first thing to verify. A single wrong digit always fails the check, and most swaps of two neighboring digits do too.
How to look up nutrition from a barcode
Scan the code with your phone or type the full number, including any leading zeros, into a barcode lookup such as the one in the Goby AI app. You will get the product name, calories, macros, ingredient list and a health score where the product is known.
Coverage depends on the database. Large national brands are almost always present; regional products, new launches and store brands may be missing or incomplete. When a result looks wrong, compare it with the nutrition panel on the pack, which is the legal source of truth.
Check that the serving size in the lookup matches how much you actually eat. Many records store values per 100g or per 100ml as well as per serving, and mixing the two is a common source of tracking errors.
Recipes change. Manufacturers sometimes reformulate a product, for example to reduce sugar, without changing the barcode. If the label in your hand disagrees with a lookup, trust the label.
Food barcode APIs for developers
If you are building an app, a food barcode API takes a GTIN and returns a structured product record. Options range from government data, such as the branded foods in USDA FoodData Central, which stores a GTIN or UPC for many products, to open crowd-sourced databases and commercial providers. Check each source's license and attribution terms before you ship.
Normalize codes before querying: strip spaces, expand UPC-E to UPC-A, and pad to 13 or 14 digits with leading zeros so the same product is not stored twice. Validate the check digit first to avoid wasted calls, and cache results because product data changes slowly.
Expect gaps: store-issued 02 and 20–29 codes never resolve, and crowd-sourced records vary in completeness, so show users which fields are missing rather than displaying zeros. Keep the per-100g and per-serving values separate in your data model.
QR codes and the move to 2D barcodes
You may notice QR codes and other 2D barcodes appearing on food packs. GS1 has a standard called GS1 Digital Link that puts the GTIN inside a web address, so one code can be scanned at the checkout and also opened by a phone to show product details. Some 2D codes can also carry a batch number or expiry date, which is useful for recalls and stock rotation.
Retailers in many markets are preparing their checkouts to read these codes, but the familiar linear barcode will stay on most packs for years. For nutrition lookups, the GTIN is still the key either way.
