Choosing a Barcode Symbology

Choosing a Barcode Symbology

Choosing a Barcode Symbology

Aspose.BarCode FOSS for Python supports seven symbologies. Each is suited to different data types, scanning environments, and industry standards. This guide covers the characteristics of each symbology and when to use it.


Symbology Overview

SymbologyTypeCharacter SetData CapacityCheck Digit
Code 1281DFull ASCII (128 characters)Variable lengthAutomatic (mod-103)
Code 391DA–Z, 0–9, and 7 special characters (base); full ASCII (extended)Variable lengthOptional
EAN-131DNumeric only (0–9)12 data digits + 1 check digitAutomatic
EAN-81DNumeric only (0–9)7 data digits + 1 check digitAutomatic
QR Code2DNumeric, alphanumeric, byte, and KanjiUp to 7,089 numeric / 4,296 alphanumericAutomatic (Reed-Solomon)
UPC-A1DNumeric only (0–9)11 data digits + 1 check digitAutomatic
UPC-E1DNumeric only (0–9)6 data digits (compressed UPC-A)Automatic

Code 128

Code 128 encodes the full ASCII character set with high density. It uses three character sets (A, B, C) and switches between them automatically in AUTO mode.

Best for: inventory labels, shipping labels, general-purpose alphanumeric data.

from aspose_barcode_foss import BarcodeService
from aspose_barcode_foss import Code128Options, Code128EncodeMode

service = BarcodeService()

# Auto mode — library selects optimal character sets
barcode = service.generate("code128", "INV-2026-00451")

# Force Code C for all-numeric data (higher density)
barcode = service.generate(
    "code128", "123456789012",
    encode=Code128Options(encode_mode=Code128EncodeMode.CODE_C),
)
svg = barcode.to_svg()

Code 39

Code 39 supports uppercase letters, digits, and 7 special characters in base mode. Enable full_ascii=True to encode the entire ASCII range. An optional check digit can be added via add_check_digit.

Best for: industrial labels, government/military identifiers (LOGMARS), and environments where simplicity is more important than density.

from aspose_barcode_foss import BarcodeService
from aspose_barcode_foss import Code39Options

service = BarcodeService()

# Base mode — uppercase + digits + special chars
barcode = service.generate("code39", "PART-A1234")

# Full ASCII mode with check digit
barcode = service.generate(
    "code39", "Part-a1234",
    encode=Code39Options(full_ascii=True, add_check_digit=True),
)
svg = barcode.to_svg()

EAN-13

EAN-13 is the standard barcode for retail products outside North America. It encodes exactly 12 data digits; the 13th digit is a check digit computed automatically. Use Ean13Options to control check digit input behavior.

Best for: retail product identification, international trade items (GTIN-13).

from aspose_barcode_foss import BarcodeService
from aspose_barcode_foss import Ean13Options

service = BarcodeService()

# 12 data digits — check digit computed
barcode = service.generate("ean13", "590123412345")

# With rendering options for human-readable text
from aspose_barcode_foss import RenderOptions
svg = barcode.to_svg(RenderOptions(show_text=True, scale=2.0))

EAN-8

EAN-8 is the compact version of EAN-13, used on small retail packages where space is limited. It encodes 7 data digits plus 1 check digit.

Best for: small retail products, items with limited label space.

from aspose_barcode_foss import BarcodeService

service = BarcodeService()
barcode = service.generate("ean8", "9638507")
svg = barcode.to_svg()

QR Code

QR Code is a 2D matrix symbology that stores large amounts of data in a small area. It supports four encoding modes via QrEncodeMode: NUMERIC, ALPHANUMERIC, BYTE, and KANJI. Error correction is configurable through QrErrorCorrectionLevel (L, M, Q, H).

Best for: URLs, mobile applications, marketing materials, and any use case requiring high data capacity or non-ASCII characters.

from aspose_barcode_foss import BarcodeService
from aspose_barcode_foss import QrOptions, QrErrorCorrectionLevel, QrEncodeMode

service = BarcodeService()

# Default settings
barcode = service.generate("qrcode", "https://example.com")

# High error correction for printed labels
barcode = service.generate(
    "qrcode", "https://example.com/product/12345",
    encode=QrOptions(
        error_correction_level=QrErrorCorrectionLevel.H,
        encoding_mode=QrEncodeMode.BYTE,
    ),
)
png = barcode.to_png()

UPC-A

UPC-A is the standard barcode for retail products in North America. It encodes 11 data digits plus 1 check digit. UPC-A is a subset of EAN-13 with a leading zero.

Best for: North American retail product identification (GTIN-12).

from aspose_barcode_foss import BarcodeService

service = BarcodeService()
barcode = service.generate("upca", "01234567890")
svg = barcode.to_svg()

UPC-E

UPC-E is a compressed form of UPC-A for small retail items. It encodes 6 data digits by suppressing zeros from the full UPC-A representation.

Best for: small retail items, coupons, and labels where space is limited.

from aspose_barcode_foss import BarcodeService

service = BarcodeService()
barcode = service.generate("upce", "0123456")
svg = barcode.to_svg()

Decision Guide

Use this table to select the right symbology for your application:

Use CaseRecommended SymbologyReason
Warehouse inventoryCode 128Full ASCII, high density, variable length
Military/LOGMARS labelsCode 39Wide adoption in government systems
International retailEAN-13GTIN-13 standard
Small retail packagingEAN-8 or UPC-ECompact physical size
North American retailUPC-AGTIN-12 standard
URLs and mobile linksQR CodeHigh capacity, 2D scanning
Marketing and printQR CodeScannable by phone cameras
All-numeric serial numbersCode 128 (Code C)Highest density for numeric data

Tips and Best Practices

  • Use Code 128 as the default for general-purpose labels — it offers the best density-to-compatibility ratio among 1D symbologies
  • For retail products, use the symbology required by your market: EAN-13 for international, UPC-A for North America
  • Set QrErrorCorrectionLevel.H for QR codes that will be printed on labels exposed to wear or partial damage
  • Always let the library compute check digits automatically rather than supplying them manually
  • Use show_text=True in RenderOptions for human-readable labels so operators can verify scanned data visually

Common Issues

IssueCauseFix
InvalidInputError on EAN-13Non-numeric characters in dataEAN-13 only accepts digits 0–9
InvalidInputError on Code 39Lowercase letters in base modeSet Code39Options(full_ascii=True)
QR code too largeVersion too low for data lengthLet the library auto-select version, or increase QrOptions.version
UPC-E InvalidInputErrorData does not match the zero-suppression patternVerify the 6-digit UPC-E format or use UPC-A instead

FAQ

Can I use Code 128 for all-numeric data?

Yes. Code 128 Code C mode (Code128EncodeMode.CODE_C) is optimized for all-numeric data, encoding pairs of digits in a single symbol character for maximum density.

What is the difference between EAN-13 and UPC-A?

UPC-A is a 12-digit subset of EAN-13. A UPC-A code can be represented as an EAN-13 with a leading zero. They are functionally compatible in retail scanning systems.

Which symbology supports the most data?

QR Code supports up to 7,089 numeric characters or 4,296 alphanumeric characters. All 1D symbologies in this library support variable-length data, but QR Code has the highest capacity.

Can I mix symbologies in a single application?

Yes. Create one BarcodeService instance and call generate() with different symbology names for each barcode. The service resolves each symbology through the SymbologyRegistry.


API Reference Summary

Class / MethodDescription
BarcodeService.generate(symbology, data, encode, render)Generate a barcode for any registered symbology
Code128OptionsEncoding options for Code 128 (encode mode, GS1, ECI)
Code128EncodeModeEnum: AUTO, CODE_A, CODE_B, CODE_C, CODE_AB, CODE_AC, CODE_BC
Code39OptionsEncoding options for Code 39 (full ASCII, check digit)
Code39EncodeModeEnum: BASE, FULL_ASCII
Ean13OptionsEncoding options for EAN-13 (check digit input)
Ean8OptionsEncoding options for EAN-8 (check digit input)
QrOptionsEncoding options for QR Code (error correction, version, mask, mode)
QrEncodeModeEnum: AUTO, NUMERIC, ALPHANUMERIC, BYTE, KANJI
QrErrorCorrectionLevelEnum: L, M, Q, H
UpcaOptionsEncoding options for UPC-A
UpceOptionsEncoding options for UPC-E
SymbologyRegistryResolves symbology names and provides definitions

See Also

 English