What is a Barcode? How Barcodes Work, Symbologies, and the Technology Behind Every Scan
Over 5 billion barcodes are scanned every single day — on grocery shelves, shipping labels, hospital wristbands, and warehouse pallets. But how does a simple pattern of black lines encode data, and what happens in the milliseconds between scan and beep? Let's explore the engineering behind the humble barcode.
Table of Contents
What is a Barcode?
A barcode is a machine-readable representation of data using a pattern of parallel lines (bars) and spaces of varying widths. The bars and spaces encode characters — typically numbers, but sometimes letters and symbols — that can be decoded by an optical scanner in milliseconds.
The term "barcode" usually refers to one-dimensional (1D) linear barcodes — the familiar pattern of vertical lines you see on product packaging, shipping labels, and ID cards. These are distinct from two-dimensional (2D) codes like QR codes that use a grid of squares.
A barcode does not contain product information like the price or name — it contains an identifier(like a product number) that links to a record in a database. When a cashier scans a barcode at checkout, the scanner reads the number, looks it up in the store's database, and retrieves the product name, price, and other details.
The History of Barcodes
The barcode's origin story begins on a beach in Miami. In 1948, graduate student Bernard Silver overheard a supermarket executive asking a university dean to research a system for automatically reading product information during checkout. Silver told his colleague Norman Joseph Woodland, who became obsessed with the idea.
Sitting on Miami Beach, Woodland dragged his fingers through the sand and had a flash of inspiration: what if Morse code — dots and dashes — were extended downward into wide and narrow lines? He filed the first barcode patent in 1949 (granted in 1952), describing a "bull's-eye" circular pattern of concentric rings.
| Year | Milestone |
|---|---|
| 1949 | Woodland and Silver file the first barcode patent (bull's-eye design) |
| 1952 | U.S. Patent 2,612,994 granted for the barcode concept |
| 1966 | First commercial barcode use: railroad car identification (KarTrak system) |
| 1971 | IBM's George Laurer develops the UPC barcode symbol |
| 1974 | First UPC barcode scanned: a 10-pack of Wrigley's Juicy Fruit gum at Marsh supermarket, Troy, Ohio |
| 1977 | European Article Numbering (EAN) system created, compatible with UPC |
| 1981 | U.S. Department of Defense adopts CODE39 (LOGMARS) for all military property |
| Today | Over 5 billion barcode scans per day worldwide; GS1 system used in 150+ countries |
The Famous First Scan
On June 26, 1974, at 8:01 AM, cashier Sharon Buchanan at Marsh Supermarket in Troy, Ohio scanned a 10-pack of Wrigley's Juicy Fruit chewing gum — the first product ever scanned with a UPC barcode. That pack of gum is now on display at the Smithsonian National Museum of American History.
How Barcodes Work
The principle behind barcodes is elegantly simple: a beam of light is swept across the barcode, and the pattern of reflections is converted into data.
Step 1: Illumination
The scanner emits a beam of light — typically a red laser (650 nm wavelength) or LED — across the barcode. The beam moves from one side of the code to the other.
Step 2: Reflection
White spaces reflect the light back to the scanner, while dark bars absorb it. This creates a pattern of reflected-and-not-reflected light as the beam crosses each bar and space.
Step 3: Detection
A photosensitive detector (photodiode) inside the scanner converts the reflected light into an analog electrical signal — a waveform of high and low voltages representing the bars and spaces.
Step 4: Decoding
The analog signal is digitized and decoded. The decoder identifies the barcode symbology (from the start/stop patterns), decodes each character by measuring bar and space widths, verifies the check digit, and outputs the data — typically as if it were typed on a keyboard.
Why Red Lasers?
Most barcode scanners use red light (650 nm) because red laser diodes are inexpensive, the wavelength provides good contrast against black and white, and the visible beam helps users aim the scanner. This is also why you should never use red or orange barsin a barcode — the red laser can't distinguish them from the white background.
Anatomy of a Barcode
Every linear barcode is composed of the same structural elements, regardless of the symbology:
Quiet Zones
Blank margins on the left and right sides. They signal to the scanner where the barcode begins and ends. The quiet zone must be at least 10 times the width of the narrowest bar(called the "X dimension"). Cutting into the quiet zone is one of the most common causes of scan failure.
Start & Stop Characters
Special bar patterns at each end that tell the scanner which symbology is being used and which direction the barcode is being read. This allows barcodes to be scanned in either direction — left-to-right or right-to-left — and still be decoded correctly.
Data Characters
The main body of the barcode. Each character is encoded as a specific pattern of bars and spaces. For example, in UPC-A, each digit is represented by a pattern of two bars and two spaces within a 7-module-wide unit.
Check Character
A calculated digit at the end that provides error detection. If the scanned data doesn't match the check digit, the scanner knows the scan was incorrect and won't accept it. EAN-13 and UPC always include a mandatory check digit.
Human-Readable Text
The numbers printed below the bars. These allow manual entry if the barcode is damaged or can't be scanned. They're not part of the machine-readable barcode itself — the scanner reads only the bars and spaces.
UPC-A barcode structure (12 digits):
┌─ Quiet ─┬─ Start ─┬── Left Data ──┬─ Center ─┬── Right Data ──┬─ Stop ─┬─ Quiet ─┐
│ Zone │ Guard │ (6 digits) │ Guard │ (6 digits) │ Guard │ Zone │
│ │ ||| │ ▐▌▐▌▐▌▐▌▐▌▐▌ │ ||||| │ ▐▌▐▌▐▌▐▌▐▌▐▌ │ ||| │ │
└─────────┴─────────┴───────────────┴──────────┴────────────────┴────────┴─────────┘
Example: 0 36000 29145 2
↑ ↑
Number System Check DigitBarcode Symbologies Explained
A symbology is the specific encoding scheme a barcode uses — the rules that define how characters are mapped to bar/space patterns. There are dozens of symbologies, each designed for specific industries and use cases. Here are the four most important:
CODE128 — The Universal Standard
CODE128 is the most versatile and widely used barcode format today. It supports the full 128-character ASCII set — uppercase and lowercase letters, all digits, punctuation, and control characters — while producing very compact barcodes.
CODE128 uses three character sets (A, B, and C) and can switch between them mid-stream for optimal encoding. Character set C is especially efficient: it encodes pairs of digits as single symbols, making numeric-only barcodes extremely compact. Smart encoders automatically choose the optimal character set.
| Character Set | Includes | Best For |
|---|---|---|
| Set A | Uppercase letters, digits, control characters | Data with control characters (ASCII 0–31) |
| Set B | Uppercase + lowercase letters, digits, punctuation | General text (most common) |
| Set C | Digit pairs (00–99) | Long numeric strings (very compact) |
GS1-128 (formerly EAN-128) is a specialized variant of CODE128 used extensively in supply chain and logistics. It uses Application Identifiers (AIs) — standardized prefixes that define the meaning of the data that follows (e.g., AI 01 = product identifier, AI 10 = batch number, AI 17 = expiration date).
CODE39 — Simple and Self-Checking
Developed in 1974 by Intermec, CODE39 was the first barcode symbology to encode letters as well as numbers. It supports 43 characters: uppercase A–Z, digits 0–9, and seven special characters (- . $ / + % and space).
CODE39's key advantage is that it's self-checking— each character pattern is distinct enough that the decoder can detect errors without a mandatory check digit. This makes it simple to implement but produces wider barcodes than CODE128. It's the standard for:
- U.S. military (MIL-STD-1189, also known as LOGMARS)
- Automotive industry (AIAG standard)
- Healthcare (HIBC — Health Industry Bar Code)
- Government IDs and asset tracking
EAN-13 — International Retail
EAN-13 (European Article Number) is the global standard for retail product identification, used in over 150 countries. It encodes a 13-digit number with a specific structure:
EAN-13 number structure:
4 006381 33393 1
↑ ↑ ↑ ↑
│ │ │ └─ Check digit (calculated)
│ │ └────── Product code (assigned by manufacturer)
│ └────────────── Company prefix (assigned by GS1)
└─────────────────── GS1 prefix / country code
Common GS1 prefixes:
00-13 USA & Canada 30-37 France
40-44 Germany 45, 49 Japan
50 UK 690-699 China
880 South Korea 890 IndiaImportant: the country prefix indicates where the GS1 company prefix was assigned, not where the product was manufactured. A product with prefix "50" was assigned its number by GS1 UK, but could be manufactured anywhere in the world.
UPC-A — North American Retail
UPC-A (Universal Product Code) is the 12-digit barcode used on virtually every retail product in the United States and Canada. It was the original retail barcode, first scanned in 1974.
UPC-A is technically a subset of EAN-13 — any UPC-A code can be converted to EAN-13 by prepending a zero. This means all EAN-13 scanners can read UPC codes, ensuring global compatibility. The structure is similar: a number system digit, a company prefix, a product number, and a check digit.
UPC vs EAN: Which Should You Use?
If you're selling products only in the US/Canada, UPC-A is sufficient. If you plan to sell internationally, use EAN-13 from the start. Since UPC-A is a subset of EAN-13, there's no downside to starting with EAN-13 — all modern scanners handle both formats. You need a GS1 company prefix for either system.
Check Digits & Error Detection
Barcodes use check digits— a calculated value appended to the data — to detect scanning errors. The scanner performs the same calculation and compares the result to the check digit encoded in the barcode. If they don't match, the scan is rejected.
Here's how the modulo 10 check digit works for EAN-13 and UPC-A:
EAN-13 check digit calculation:
Example: 400638133393?
Step 1: Number the digits from right to left (excluding check digit)
4 0 0 6 3 8 1 3 3 3 9 3
Pos: 1 2 3 4 5 6 7 8 9 10 11 12
Step 2: Sum digits in odd positions × 1, even positions × 3
Odd positions (1,3,5,7,9,11): 4+0+3+1+3+9 = 20 × 1 = 20
Even positions (2,4,6,8,10,12): 0+6+8+3+3+3 = 23 × 3 = 69
Step 3: Total = 20 + 69 = 89
Step 4: Check digit = (10 - (89 mod 10)) mod 10
= (10 - 9) mod 10
= 1
Result: 4006381333931 ✓This algorithm catches all single-digit errors and most transposition errors (swapping two adjacent digits). It's not as powerful as multi-character error correction in QR codes (Reed-Solomon), but for the short numeric data in retail barcodes, a check digit is sufficient.
Error Detection vs Error Correction
A check digit can detect that an error occurred, but it cannot correct the error — the scanner simply rejects the scan and the operator tries again. This is different from QR codes, which use Reed-Solomon error correction to recover the correct data even when part of the code is damaged.
GS1 and the Global Barcode System
GS1 (Global Standards 1) is the nonprofit organization that manages the global barcode numbering system. If you want to sell a product in a retail store — anywhere in the world — you need a GS1 company prefix.
GS1 ensures that every barcode number is globally unique. No two products anywhere in the world should ever have the same barcode number. The system works through a hierarchy:
- GS1 assigns country/region prefixes to its member organizations (e.g., GS1 US manages prefixes 00–13)
- Member organizations assign company prefixes to businesses (e.g., a 7–10 digit prefix for each company)
- Companies assign product numbers within their prefix range to their individual products
- The check digit is calculated mathematically from the other digits
Do You Need a GS1 Prefix?
Yes, if you're selling products in retail stores (physical or online marketplaces like Amazon). No, if you're using barcodes for internal purposes only (inventory tracking, asset management, internal logistics). For internal use, you can encode any data you want — just use CODE128 or CODE39 with your own numbering system.
How Barcode Scanners Work
There are several types of barcode scanners, each with different technology and use cases:
| Type | Technology | Range | Common Use |
|---|---|---|---|
| Laser Scanner | Red laser diode + oscillating mirror | Up to ~60 cm | Retail POS, general purpose |
| CCD (Linear Imager) | LED + CCD sensor array | Up to ~30 cm | Close-range scanning |
| 2D Imager | Camera sensor (CMOS/CCD) | Up to ~50 cm | 1D + 2D codes, mobile scanning |
| Long-Range Laser | High-power laser + reflective optics | Up to ~15 m | Warehouses, shipping yards |
Modern smartphones can also scan barcodes using their built-in camera and image processing software. While not as fast or reliable as dedicated scanners, smartphone scanning has made barcode technology accessible to consumers for price comparison, product lookup, and inventory management.
1D Barcodes vs 2D Codes
Traditional 1D barcodes and 2D codes (like QR codes, Data Matrix, and PDF417) serve different purposes:
| Feature | 1D Barcode | 2D Code |
|---|---|---|
| Data capacity | ~20–25 characters | Up to ~7,000 characters |
| Data types | Numbers + limited text | Text, URLs, binary, images |
| Error correction | Check digit only (detection) | Reed-Solomon (correction) |
| Scan direction | Horizontal (bidirectional) | Any angle (omnidirectional) |
| Speed | Very fast (laser) | Fast (image-based) |
| Cost of scanner | Low (laser diode) | Medium (camera + processor) |
| Industry standard | Retail POS, logistics | Marketing, mobile, healthcare |
1D barcodes remain the standard for point-of-sale retail scanning because they're fast, cheap to produce, and the entire retail infrastructure is built around them. 2D codes are preferred when you need to encode more data, link to digital content, or enable consumer interaction via smartphones. Many modern applications use both — a UPC barcode for the checkout scanner and a QR code for the customer to scan.
Real-World Applications
Barcodes are one of the most successful technologies in human history, touching nearly every industry:
Retail & Point of Sale: The original use case. UPC and EAN barcodes on product packaging enable automated checkout, instant price lookup, inventory management, and sales tracking across millions of retail stores worldwide.
Supply Chain & Logistics: CODE128 and GS1-128 barcodes track packages from manufacturer to warehouse to delivery truck to your doorstep. FedEx, UPS, and postal services worldwide rely on barcodes for sorting and routing billions of packages annually.
Healthcare: Hospital wristbands use barcodes to verify patient identity, reducing medication errors. Prescription labels, blood bags, laboratory specimens, and medical devices all carry barcodes for safety and traceability.
Library Systems:Library books have carried barcodes since the 1970s. Scanning a book's barcode and a patron's library card automates check-out and check-in, replacing handwritten logs.
Manufacturing:Work-in-progress (WIP) barcodes track parts through assembly lines. This was the original motivation behind QR codes — Toyota's Denso Wave needed to track automotive parts more efficiently than 1D barcodes allowed.
Ticketing & Access Control: Boarding passes, concert tickets, event entries, and loyalty cards all use barcodes for fast, reliable identification.
Asset Tracking: Companies label equipment, tools, IT hardware, and furniture with barcodes for inventory management and depreciation tracking. The U.S. Department of Defense requires CODE39 barcodes on all military property.
Best Practices for Creating Barcodes
Follow these guidelines to ensure your barcodes scan reliably every time:
- Use high contrast: Black on white is the gold standard. If using colors, the bars must be significantly darker than the background. Never use red, orange, or yellow bars — most barcode scanners use red lasers that cannot distinguish these colors from white.
- Respect the quiet zone: Leave at least 10× the X dimension (narrowest bar width) of empty space on each side. For a barcode with 0.33mm bars, that's at least 3.3mm of margin on each side.
- Don't truncate bar height: Taller bars give the scanner's laser more room to cross the barcode, improving read reliability. The GS1 specification recommends a minimum height of 25.9mm for EAN-13 at standard magnification.
- Print at 300 DPI or higher: Low-resolution printing can blur the edges of narrow bars, making them wider than intended and causing scan failures.
- Use SVG for print: Vector formats scale perfectly to any size. PNG works for digital use but can pixelate when resized for print.
- Test before mass printing: Always verify your barcode with at least two different scanners before committing to a production print run. GS1 offers barcode verification services.
- Place on flat surfaces: Avoid printing barcodes across seams, folds, perforations, or curved surfaces. If a barcode must go on a curve, orient the bars parallel to the axis of curvature (so the scanner reads along the flat direction).
- Keep it square: Never stretch or compress a barcode horizontally or vertically. Distorting the aspect ratio changes the bar-to-space width ratios and will cause scan failures.
The Future of Barcodes
After 50 years, barcodes show no signs of disappearing. Instead, they're evolving:
GS1 Digital Link
GS1 is developing a system where a single 2D barcode (like a QR code) can serve double duty — the scanner at checkout reads the product identifier, while a consumer scanning the same code gets a link to product information, nutritional data, or promotional content.
Sunrise 2027
GS1's "Sunrise 2027" initiative aims to transition retail from 1D barcodes to 2D codes at point of sale. By 2027, retailers worldwide should be ready to accept 2D barcodes (including QR codes and Data Matrix) at checkout — though 1D barcodes will continue to be accepted for years afterward.
RFID and Beyond
RFID (Radio Frequency Identification) tags don't require line-of-sight scanning and can be read at a distance, making them attractive for logistics and inventory. However, RFID tags cost 5–15¢ each versus fractions of a cent for printed barcodes, so barcodes remain far more cost-effective for consumer products.
The barcode's simplicity, near-zero cost, and universal infrastructure make it almost impossible to replace entirely. Over 50 years after that first pack of gum was scanned, the barcode remains one of the most impactful inventions of the 20th century.
Generate Barcodes Instantly
Use our free Barcode Generator to create professional barcodes in CODE128, CODE39, EAN-13, and UPC formats. Customize colors and dimensions, then download as PNG or SVG — all in your browser with complete privacy.
Try Barcode Generator →References
- GS1. GS1 General Specifications. https://www.gs1.org/standards/barcodes-epcrfid-id-keys/gs1-general-specifications
- ISO/IEC. ISO/IEC 15420:2009 — Information technology — Automatic identification and data capture techniques — EAN/UPC bar code symbology specification. https://www.iso.org/standard/46143.html
- Woodland, N.J. & Silver, B. (1952). Classifying apparatus and method. U.S. Patent 2,612,994.
- Smithsonian National Museum of American History. Barcode. https://americanhistory.si.edu/collections/object-groups/barcode
- GS1. Sunrise 2027 — Transition to 2D barcodes at point of sale. https://www.gs1.org/industries/retail/sunrise-2027