Barcode Types Explained -- UPC, EAN, Code 128, QR, and When to Use Each

Learn how different barcode symbologies work, what each type is designed for, and how to choose the right barcode for retail, shipping, inventory, or general data encoding.

The Quick Answer

A barcode is a machine-readable representation of data using parallel lines (1D) or patterns of squares (2D), widely used for product identification, inventory tracking, and data encoding.

The barcode on a grocery item is typically a UPC-A (12 digits, US/Canada) or EAN-13 (13 digits, international). Shipping labels commonly use Code 128. Outer cartons use ITF-14. For encoding URLs, text, or large data payloads, QR codes are the standard.

Choosing the right barcode type depends on what you are encoding, where it will be printed, and what scanners will read it.

Generate barcodes instantly with our Barcode Generator or create QR codes with the QR Code Generator.


How Barcodes Work

A barcode encodes data in the relative widths of bars and spaces. A scanner (laser or camera-based) reads the pattern by detecting transitions between dark and light regions. The scanner converts these transitions into a digital signal, decodes it according to the symbology's rules, and outputs the encoded data -- typically a number that gets looked up in a database.

The term symbology refers to the specific encoding standard: the rules for how characters map to bar patterns. UPC, EAN, Code 128, and Code 39 are all different symbologies.

1D vs 2D

1D (linear) barcodes encode data along one axis -- the horizontal width of bars and spaces. The height of the bars is just for ease of scanning and carries no data.

2D barcodes encode data in both horizontal and vertical dimensions, using grids of squares (QR codes), stacked rows (PDF417), or circular patterns (Data Matrix). This allows far greater data density.


1D Barcode Types

UPC-A (Universal Product Code)

The standard retail barcode in the United States and Canada.

  • Length: 12 digits (11 data + 1 check digit)
  • Structure: 1-digit number system + 5-digit manufacturer code + 5-digit product code + 1 check digit
  • Character set: Numeric only (0-9)
  • Managed by: GS1

UPC-A is what you see on virtually every product at a US grocery store, pharmacy, or retail shop. The number uniquely identifies the product; the price and description are stored in the retailer's point-of-sale database, not in the barcode itself.

UPC-E

A compressed version of UPC-A designed for small packages where a full-size barcode will not fit.

  • Length: 6 digits (displayed), derived from a 12-digit UPC-A by suppressing zeros
  • Use case: Small items like candy bars, lip balm, and individually sold items

UPC-E can only represent UPC-A codes that contain specific patterns of zeros in the manufacturer or product code. Not every UPC-A can be compressed to UPC-E.

EAN-13 (European Article Number)

The international standard for retail product identification, defined in ISO/IEC 15420.

  • Length: 13 digits (12 data + 1 check digit)
  • Structure: 2-3 digit GS1 country prefix + manufacturer code + product code + check digit
  • Character set: Numeric only (0-9)

EAN-13 is a superset of UPC-A. Every UPC-A code can be expressed as an EAN-13 by adding a leading zero. For example, UPC-A 012345678905 becomes EAN-13 0012345678905.

The country prefix indicates where the barcode was registered, not where the product was manufactured. Common prefixes: 00-13 (US/Canada), 30-37 (France), 40-44 (Germany), 45/49 (Japan), 690-699 (China).

EAN-8

A compact 8-digit version of EAN-13 for small products.

  • Length: 8 digits (7 data + 1 check digit)
  • Use case: Items too small for a full EAN-13 barcode

EAN-8 codes are assigned directly by GS1 member organizations, not derived from a company prefix. They are less common because the number space is more limited.

Code 128

A high-density, variable-length barcode used extensively in logistics, shipping, and supply chain operations. Defined in ISO/IEC 15417.

  • Length: Variable (no fixed limit; practical scanning limit around 40-50 characters)
  • Character set: Full ASCII (128 characters) -- letters, digits, symbols, and control characters
  • Density: Very high -- encodes more data per unit width than Code 39

Code 128 uses three character subsets (A, B, C) and can switch between them mid-barcode to optimize density. Subset C is especially efficient for numeric data, encoding two digits in one symbol width.

Where you see it: Shipping labels (FedEx, UPS, USPS), GS1-128 labels on pallets and cases, inventory labels, library books.

Code 39

An older alphanumeric barcode still widely used in government, military, and healthcare.

  • Length: Variable
  • Character set: Uppercase A-Z, digits 0-9, and seven special characters (- . $ / + % space)
  • Self-checking: Each character can be verified independently without a check digit (though a check digit can be added)

Code 39 is lower density than Code 128, meaning it produces wider barcodes for the same data. Its advantage is simplicity and the self-checking property, which reduces misreads.

Where you see it: US Department of Defense (LOGMARS), healthcare labels (HIBC), automotive industry part labels, ID badges.

ITF-14 (Interleaved Two of Five)

Designed specifically for marking outer shipping cartons and cases.

  • Length: 14 digits (13 data + 1 check digit)
  • Character set: Numeric only
  • Key feature: Wide bars and high tolerance for print variation, making it reliable on corrugated cardboard

The first digit is the packaging indicator (identifying the packaging level), followed by the 13-digit GTIN of the product inside.

Where you see it: Outer cases and cartons in warehouses, distribution centers, and retail backrooms.


2D Barcodes (Brief Overview)

2D codes encode data in two dimensions, offering dramatically higher capacity. The three most common types:

Type Max Capacity Primary Use
QR Code 4,296 alphanumeric chars URLs, payments, marketing, WiFi sharing
Data Matrix 2,335 alphanumeric chars Small parts marking, electronics, pharmaceuticals
PDF417 1,850 alphanumeric chars Driver's licenses, boarding passes, shipping labels

For a deep dive into QR code structure, encoding modes, and error correction, see our complete QR code guide.


Comparison Table

Symbology Digits/Chars Numeric Only? Fixed Length? Primary Use
UPC-A 12 Yes Yes US/Canada retail products
UPC-E 6 (compressed) Yes Yes Small retail packages
EAN-13 13 Yes Yes International retail products
EAN-8 8 Yes Yes Small international products
Code 128 Variable No (full ASCII) No Shipping, logistics, inventory
Code 39 Variable No (alphanumeric) No Military, healthcare, automotive
ITF-14 14 Yes Yes Outer shipping cartons
QR Code Up to 4,296 No (multi-mode) No URLs, data encoding, mobile

How the Check Digit Works

UPC and EAN barcodes use a modulo 10 (mod-10) check digit algorithm to catch scanning errors. Here is how it works for a UPC-A barcode:

Worked Example

Calculate the check digit for the first 11 digits: 03600029145_

  1. Number the positions 1 through 11 from left to right
  2. Multiply digits in odd positions (1, 3, 5, 7, 9, 11) by 3
  3. Multiply digits in even positions (2, 4, 6, 8, 10) by 1
  4. Sum all the results:
Position:  1  2  3  4  5  6  7  8  9  10  11
Digit:     0  3  6  0  0  0  2  9  1   4   5
Multiply:  x3 x1 x3 x1 x3 x1 x3 x1 x3  x1  x3
Result:    0  3  18 0  0  0  6  9  3   4   15

Sum = 0 + 3 + 18 + 0 + 0 + 0 + 6 + 9 + 3 + 4 + 15 = 58

  1. Take the sum modulo 10: 58 mod 10 = 8
  2. Subtract from 10: 10 - 8 = 2
  3. If the result is 10, the check digit is 0. Otherwise, the result is the check digit.

Check digit = 2. The full UPC-A is 036000291452.

This catches the most common scanning errors: single-digit misreads and adjacent digit transpositions. If even one digit is wrong, the check digit calculation will fail and the scanner will reject the read.


How to Choose the Right Barcode

Selling retail products in the US/Canada? Use UPC-A. You will need a GS1 company prefix.

Selling products internationally? Use EAN-13. Register through your country's GS1 member organization.

Shipping labels and logistics? Use Code 128 (specifically GS1-128 for supply chain applications).

Outer cartons and cases? Use ITF-14. It prints reliably on corrugated surfaces.

Internal inventory or asset tracking? Use Code 128 or Code 39 -- no GS1 registration needed for internal use.

Encoding URLs, WiFi credentials, or text for mobile scanning? Use a QR code. See our QR Code Generator.


Try It

Create barcodes in any major format with our Barcode Generator -- supports UPC-A, EAN-13, Code 128, Code 39, ITF-14, and more. Download as SVG or PNG.

For QR codes and 2D encoding, use our QR Code Generator and read the full guide to how QR codes work.


FAQ

What is the difference between UPC and EAN barcodes?

UPC-A is a 12-digit barcode used primarily in the United States and Canada. EAN-13 is a 13-digit barcode used internationally. EAN-13 is a superset of UPC-A -- every UPC-A code can be represented as an EAN-13 by adding a leading zero. Both are managed by GS1 and serve the same purpose: uniquely identifying retail products at the point of sale.

How many digits are in a barcode?

It depends on the type. UPC-A has 12 digits, UPC-E has 6, EAN-13 has 13, EAN-8 has 8, and ITF-14 has 14. Code 128 and Code 39 are variable-length and can encode as many characters as needed (within practical scanning limits). There is no single universal barcode length.

Can I create my own barcode?

Yes, for internal use. You can generate barcodes with any data you choose for inventory tracking, asset management, or personal projects. However, for products sold in retail stores, you must obtain a GS1 company prefix and use valid GTINs (Global Trade Item Numbers). You cannot invent a UPC or EAN number for commercial sale.

What is a check digit and how does it work?

A check digit is the last digit of a UPC or EAN barcode, calculated from the preceding digits using a modulo 10 algorithm. It catches scanning errors -- if the scanner misreads a digit, the check digit will not match and the scan is rejected. See the worked example above for the full calculation.

Why do some products have different barcodes in different countries?

Products in the US and Canada use UPC-A (12 digits), while internationally distributed products use EAN-13 (13 digits). The first 2-3 digits of an EAN-13 are a GS1 country prefix indicating where the barcode was registered, not where the product was manufactured. Some products carry both formats for global distribution.

What barcode type is used for shipping boxes?

ITF-14 is the standard for outer shipping cartons and cases. It uses 14 digits and is engineered to print reliably on corrugated cardboard with wide bar tolerances. For individual shipping labels (the ones you see on packages from carriers), Code 128 is more common.

What is the difference between 1D and 2D barcodes?

1D barcodes encode data in the widths and spacing of parallel vertical lines, read by scanning in one horizontal direction. 2D barcodes encode data in a grid pattern across both width and height. 1D barcodes typically hold 8-50 characters; 2D codes like QR can hold thousands.

Which barcode type holds the most data?

Among 1D barcodes, Code 128 has the highest practical capacity at around 40-50 characters. Among 2D codes, QR codes hold up to 4,296 alphanumeric characters, and PDF417 holds up to 1,850. If data capacity is the priority, QR codes are the best choice.

Can a phone camera scan regular barcodes or only QR codes?

Most modern smartphones can scan both QR codes and common 1D barcodes (UPC-A, EAN-13, Code 128) using the built-in camera app or a scanner app. 1D barcodes require a closer, steadier scan because the thin lines must be read precisely, while QR codes are designed for quick scanning at various distances and angles.

Do barcode numbers contain information about the product?

UPC and EAN numbers contain a company prefix (identifying the manufacturer) and an item reference number, but the digits themselves do not describe the product. The product name, price, weight, and category are stored in a database that the retailer's point-of-sale system queries when the barcode is scanned. The barcode is just a lookup key.

Related Tools