Types of Barcodes Explained: 1D vs 2D Codes
From the familiar stripes on grocery products to the square QR codes on restaurant menus — there are dozens of barcode formats, each designed for specific use cases. Here's a complete overview.
What is a Barcode?
A barcode is a machine-readable representation of data. It uses patterns of lines, dots, or squares to encode numbers, text, or binary data that can be quickly read by optical scanners or cameras.
Barcodes fall into two main categories: 1D (one-dimensional) barcodes that use parallel lines of varying width, and 2D (two-dimensional) codes that use patterns of squares, dots, or other shapes in a matrix.
1D Barcodes (Linear Barcodes)
One-dimensional barcodes encode data in a single row of parallel lines with varying widths and spacings. They're read by scanning a laser or light across the bars horizontally.
EAN-13 (European Article Number)
The most widely used barcode standard globally. EAN-13 encodes a 13-digit number and is found on virtually every retail product outside of North America. The first 2-3 digits represent the country code, followed by the manufacturer code, product code, and a check digit.
- Characters: 13 numeric digits
- Use cases: Retail products, groceries, books (as ISBN-13)
- Example: 5901234123457
UPC-A (Universal Product Code)
The standard barcode for retail products in the United States and Canada. UPC-A encodes 12 digits and is essentially a subset of EAN-13 (a UPC-A code is equivalent to an EAN-13 with a leading zero).
- Characters: 12 numeric digits
- Use cases: US/Canadian retail, point-of-sale systems
- Example: 042100005264
Code 128
A high-density barcode that can encode all 128 ASCII characters — including lowercase letters, special characters, and control codes. It's one of the most versatile 1D formats.
- Characters: Full ASCII set (128 characters)
- Use cases: Shipping labels, GS1-128 logistics, inventory management
- Variants: Code 128A (uppercase + control), Code 128B (upper + lower), Code 128C (numeric pairs)
Code 39
One of the oldest barcode formats, Code 39 can encode uppercase letters, digits, and a few special characters. It's self-checking (no check digit required) and easy to implement.
- Characters: A-Z, 0-9, -, ., $, /, +, %, space
- Use cases: Military (LOGMARS), automotive industry, name badges
Codabar
An older format still used in specific industries. It encodes digits and a few special characters, with start/stop characters that indicate reading direction.
- Characters: 0-9, -, $, :, /, ., +
- Use cases: Libraries, blood banks, FedEx airbills
ITF (Interleaved 2 of 5)
A compact numeric-only barcode that encodes pairs of digits. Used primarily in distribution and warehouse applications where space is limited.
- Characters: Numeric only (must be even number of digits)
- Use cases: Carton labeling (ITF-14), distribution
EAN-8
A compact version of EAN-13 for small products. Encodes 8 digits and is used when the product is too small for a full EAN-13 barcode.
- Characters: 8 numeric digits
- Use cases: Small packages, candy bars, cigarettes
2D Codes (Two-Dimensional Codes)
Two-dimensional codes store data in both horizontal and vertical directions, allowing them to hold much more information than 1D barcodes. They can be read by cameras and image-based scanners.
QR Code (Quick Response)
The most popular 2D code format, QR codes can store up to 7,089 numeric characters or 4,296 alphanumeric characters. They feature built-in error correction and can be scanned from any angle.
- Capacity: Up to 4,296 alphanumeric characters
- Error correction: 4 levels (L/M/Q/H, up to 30% recovery)
- Use cases: URLs, payments, WiFi, vCards, marketing, tickets
Data Matrix
A compact 2D code commonly used in industrial and manufacturing applications. It's especially good for marking small items like electronic components due to its small minimum size.
- Capacity: Up to 2,335 alphanumeric characters
- Use cases: Electronic components, pharmaceutical packaging, aerospace parts
- Advantage: Very small size capability, high data density
PDF417
A stacked linear barcode format that can encode large amounts of data. Unlike a true 2D code, PDF417 is actually multiple rows of 1D barcodes stacked on top of each other.
- Capacity: Up to 1,850 alphanumeric characters
- Use cases: Driver's licenses, boarding passes, government IDs
- Advantage: Can be read by linear scanners (row by row)
Aztec Code
A 2D code with a distinctive bullseye-like center pattern. It doesn't require a quiet zone (blank border), making it space-efficient.
- Capacity: Up to 3,832 alphanumeric characters
- Use cases: Transport tickets, airline boarding passes (especially European rail)
- Advantage: No quiet zone needed, compact
Comparison: 1D vs 2D
| Feature | 1D Barcode | 2D Code |
|---|---|---|
| Data capacity | 20-25 characters typical | Hundreds to thousands of characters |
| Data types | Usually numeric only | Text, URLs, binary, images |
| Error correction | Check digit only | Reed-Solomon (significant damage recovery) |
| Scanner required | Laser or linear scanner | Camera or image scanner |
| Scan direction | Must be horizontal | Any angle |
| Size | Width varies by data | Compact, fixed aspect ratio |
| Cost to implement | Lower (laser scanners cheaper) | Camera-based (phones work) |
Choosing the Right Barcode Format
- Retail product labeling: EAN-13 (international) or UPC-A (US/Canada)
- Shipping and logistics: Code 128 or GS1-128
- Marketing and URLs: QR code
- Small parts marking: Data Matrix
- ID documents: PDF417
- Transport tickets: Aztec code
- General inventory: Code 39 or Code 128