← Learn

What Is a Barcode?

Updated 8 May 2026

A plain-English guide to barcodes — how 1D and 2D barcodes work, the difference between Code 128, EAN-13, UPC, and QR codes, and when to use each type.

How a barcode works

A barcode encodes data as a series of parallel bars and spaces of varying widths. A scanner shines a beam of light (usually a laser or LED) across the barcode. Dark bars absorb the light; white spaces reflect it back. The scanner converts the pattern of light and dark into a timing signal, which is decoded into numbers or characters.

Traditional barcodes are one-dimensional (1D) — data flows in one direction, left to right. The height of the bars does not carry information; it just makes the barcode easier to scan if the beam is not perfectly aligned.

Common barcode types

SymbologyDataTypical use
Code 128Any ASCII (~80 chars)Shipping, inventory, serial numbers
Code 39Alphanumeric uppercase (~43 chars)Industrial, healthcare, government
EAN-13Exactly 13 digitsRetail products (global)
UPC-AExactly 12 digitsRetail products (North America)
ITF-1414 digitsShipping cartons (outer packaging)
QR CodeUp to ~4,000 charsURLs, Wi-Fi, contact details (2D)
Data MatrixUp to ~2,335 charsSmall labels, electronics, pharma (2D)

EAN-13 and UPC — retail barcodes

Every product on a shop shelf has an EAN-13 or UPC barcode. These are not just random numbers — they are registered identifiers managed by GS1, the global standards body. The digits encode:

  • Country prefix (first 2–3 digits) — identifies the GS1 member organisation, not necessarily the country of manufacture
  • Company prefix — uniquely identifies the manufacturer
  • Product reference — assigned by the manufacturer
  • Check digit (last digit) — calculated from the others; if it does not match, the scan is rejected

To sell products in retail, you need to register with GS1 and obtain a valid company prefix. Using fake or unregistered EAN/UPC numbers in a commercial product is not permitted.

1D vs 2D barcodes

Traditional barcodes (Code 128, EAN-13, UPC) store data in one dimension — the width of bars and spaces along a horizontal line. The maximum capacity is roughly 80 characters.

Two-dimensional barcodes like QR codes and Data Matrix store data in a grid of cells, encoding information in both horizontal and vertical directions. This allows far more data — a QR code can hold up to 4,296 alphanumeric characters — and can be scanned from any angle with a camera.

For most consumer-facing use cases (sharing URLs, Wi-Fi credentials, contact details), a QR code is the better choice. For supply chain, shipping labels, and inventory where a laser scanner is used, 1D barcodes like Code 128 are the standard.

Related guides

Generate a barcode online

Code 128, Code 39, EAN-13, UPC-A, ITF-14 — download as PNG

Open Barcode Generator →