Barcodes are everywhere — on grocery products, shipping labels, event tickets, and warehouse shelves. But when you need to create one yourself, the landscape of formats is confusing: CODE128, EAN-13, UPC-A, EAN-8, GS1-128... which do you actually need?

This guide explains how the major 1D barcode formats work, when to use each one, how the check digit works, and how to generate barcodes for free in your browser, in code, or for print.

How Barcodes Work

A 1D barcode encodes data as a series of parallel bars of varying widths and the spaces between them. A barcode scanner shines a light across the symbol and measures the difference in reflectivity between the dark bars and light spaces, converting the pattern back to data.

The first commercial barcode was scanned in 1974 at a Marsh supermarket in Troy, Ohio — a pack of Wrigley's Juicy Fruit gum. The format used was UPC-A, which is still in use today.

1D Barcodes vs QR Codes

1D BarcodeQR Code
DimensionsHorizontal onlyHorizontal + vertical
Data capacityUp to ~80 charactersUp to 7,089 digits
ScannerLaser scanner or smartphonePrimarily smartphone camera
Main useRetail POS, logistics, inventoryURLs, payments, marketing
Damage toleranceLow — partial damage causes read failureHigh — up to 30% damage recoverable

Industrial scanners optimized for high-speed, long-distance reading work best with 1D barcodes. For consumer-facing use cases where smartphones are the reader, QR codes are usually the better choice.

Major Barcode Formats

CODE128 — The Universal Standard

CODE128 encodes all 128 ASCII characters (letters, digits, symbols, control codes) at high density. It is the most versatile 1D barcode and the dominant format for logistics, inventory management, and general-purpose labeling.

  • Letters, numbers, symbols — any ASCII combination
  • GS1-128 (formerly EAN-128) is an application-layer extension of CODE128 used in supply chains
  • Used on Amazon shipping labels, courier waybills, hospital wristbands
// Examples of CODE128 data
ORDER-2024-10-15-00123
PART#XYZ-789-A
SN:abc1234567

EAN-13 — International Retail Standard

EAN-13 (European Article Number) is the global retail product barcode. It encodes 13 digits, with the first two or three digits identifying the country of GS1 registration. Retailers scan these at POS systems to look up prices.

  • 13 digits only (last digit is the check digit)
  • Requires a GS1 company prefix for commercial distribution
  • Country codes: 00–09 = USA/Canada, 30–37 = France, 40–44 = Germany, 45–49 = Japan, 50 = UK

EAN-8 — Compact Retail Barcode

EAN-8 is the short form of EAN-13, using 8 digits. Used when packaging is too small for the full 13-digit symbol — think lipstick, candy bars, or small stationery.

UPC-A — North American Retail Standard

UPC-A (Universal Product Code) is the 12-digit retail barcode used throughout the United States and Canada. It is effectively a subset of EAN-13 (a leading zero is prepended to make 13 digits), so modern POS systems can scan both interchangeably.

Understanding the Check Digit

The last digit of EAN-13, EAN-8, and UPC-A barcodes is a check digit — a mathematically derived value used to detect scanning errors. If a scanner misreads a bar, the computed check digit will not match the one encoded, and the scan is rejected.

EAN-13 check digit algorithm (for the first 12 digits 490123456789):

// Positions:   1  2  3  4  5  6  7  8  9 10 11 12
// Digits:      4  9  0  1  2  3  4  5  6  7  8  9
// Weights:     1  3  1  3  1  3  1  3  1  3  1  3
// Products:    4 27  0  3  2  9  4 15  6 21  8 27

// Sum = 4+27+0+3+2+9+4+15+6+21+8+27 = 126
// Check digit = (10 - (126 % 10)) % 10 = 4

// Final barcode: 4901234567894

The Barcode Generator calculates the check digit automatically when you enter 12 digits for EAN-13.

How to Create Barcodes

Free Browser Generator (No Registration)

Use the Barcode Generator to create CODE128, EAN-13, EAN-8, and UPC-A barcodes instantly. Download as SVG (print-quality vector) or PNG.

Print-Quality Guidelines

  • Use SVG for print: SVG is vector-based — it scales to any size without blurring. PNG bitmaps become pixelated when enlarged, which causes scan failures
  • Minimum bar width: 0.25 mm (X-dimension) is the practical minimum for reliable scanning. Wider is better
  • Quiet zones: Leave a clear margin on both sides — EAN-13 requires 7 modules of white space on each side. The generator includes these automatically
  • Contrast: Black bars on white is optimal. Avoid red bars (transparent to infrared scanners), metallic substrates, and low-contrast color combinations

Generating Barcodes in Code

// JavaScript: JsBarcode
import JsBarcode from 'jsbarcode';
JsBarcode('#svg', '123456789012', { format: 'EAN13', width: 2, height: 100 });

// Python: python-barcode
import barcode
from barcode.writer import ImageWriter
ean = barcode.get('ean13', '123456789012', writer=ImageWriter())
ean.save('barcode')

// PHP: picqer/php-barcode-generator
$generator = new Picqer\Barcode\BarcodeGeneratorPNG();
file_put_contents('barcode.png',
    $generator->getBarcode('123456789012', $generator::TYPE_EAN_13));

GS1 Registration for Retail Distribution

To sell products in retail stores or on major e-commerce platforms (Amazon, Walmart, Target), you need a GS1-registered barcode. GS1 is the global non-profit standards organization that issues company prefixes.

  • GS1 US: Annual fee starts at around $250/year for up to 10 products
  • GS1 UK / GS1 Japan: Similar structure with local pricing
  • Amazon: Requires GS1-issued GTINs for most product listings

The Barcode Generator is designed for internal use, prototyping, inventory management, and testing. Do not use self-generated codes in external retail distribution without GS1 registration — collisions with other companies' product codes can cause serious problems.

FAQ

Can I scan the generated barcodes with my smartphone?
Yes. EAN-13, EAN-8, and UPC-A are natively supported by iOS Camera (iOS 11+) and Android's Google Lens. CODE128 scanning may require a dedicated barcode scanner app. All generated barcodes conform to ISO/IEC standards.
Why is my barcode not scanning?
Try these steps in order: ①Use SVG for crisp output ②Make the barcode larger (minimum 2 cm wide recommended for print) ③Ensure adequate quiet zones on both sides ④Check that bar/background contrast is sufficient ⑤Test with multiple scanner models — some are more sensitive than others.
What is the difference between EAN-13 and UPC-A?
UPC-A has 12 digits (used in North America); EAN-13 has 13 digits (used internationally). UPC-A is a strict subset of EAN-13 — prepending a leading zero converts any UPC-A to its EAN-13 equivalent. Modern POS systems and scanners handle both transparently.
Can I use a self-generated barcode on Amazon?
Amazon generally requires GS1-issued GTINs (EAN-13/UPC-A) for product listings. Exceptions exist for private-label brands enrolled in Amazon Brand Registry, which may qualify for a GTIN exemption. Check the Amazon Seller Central documentation for current requirements.
Does barcode color matter?
Yes. Classic laser scanners use infrared or red light — red bars on a white background appear invisible to them (no contrast). Black bars on white are universally reliable. If you must use color, ensure the bars are darker than the background in the wavelength your scanner uses. Always test before a print run.

Summary

  • Use CODE128 for any general-purpose encoding — it supports all ASCII characters and is the logistics industry standard.
  • Use EAN-13 (or UPC-A in North America) for retail products. GS1 registration is required for commercial distribution.
  • The check digit is calculated automatically — enter 12 digits and the generator handles the last digit.
  • For printing: always export as SVG, preserve quiet zones, and use black bars on white background.
  • Generate barcodes instantly at Barcode Generator — SVG and PNG download, no registration required.