---
Product: barcode
Platform: python
Page Type: docs
Canonical URL: https://docs.aspose.org/barcode/python/developer-guide/symbology-guide
---

# Choosing a Barcode Symbology

How to select the right barcode symbology in Aspose.BarCode FOSS for Python. Covers Code 128, Code 39, EAN-13, EAN-8, QR Code, UPC-A, and UPC-E with data capacity, character sets, and use-case guidance.

## Overview

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

| Symbology | Type | Character Set | Data Capacity | Check Digit |
|-----------|------|--------------|---------------|-------------|
| Code 128 | 1D | Full ASCII (128 characters) | Variable length | Automatic (mod-103) |
| Code 39 | 1D | A–Z, 0–9, and 7 special characters (base); full ASCII (extended) | Variable length | Optional |
| EAN-13 | 1D | Numeric only (0–9) | 12 data digits + 1 check digit | Automatic |
| EAN-8 | 1D | Numeric only (0–9) | 7 data digits + 1 check digit | Automatic |
| QR Code | 2D | Numeric, alphanumeric, byte, and Kanji | Up to 7,089 numeric / 4,296 alphanumeric | Automatic (Reed-Solomon) |
| UPC-A | 1D | Numeric only (0–9) | 11 data digits + 1 check digit | Automatic |
| UPC-E | 1D | Numeric 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.

```python
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.

```python
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).

```python
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.

```python
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.

```python
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).

```python
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.

```python
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 Case | Recommended Symbology | Reason |
|----------|----------------------|--------|
| Warehouse inventory | Code 128 | Full ASCII, high density, variable length |
| Military/LOGMARS labels | Code 39 | Wide adoption in government systems |
| International retail | EAN-13 | GTIN-13 standard |
| Small retail packaging | EAN-8 or UPC-E | Compact physical size |
| North American retail | UPC-A | GTIN-12 standard |
| URLs and mobile links | QR Code | High capacity, 2D scanning |
| Marketing and print | QR Code | Scannable by phone cameras |
| All-numeric serial numbers | Code 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

| Issue | Cause | Fix |
|-------|-------|-----|
| `InvalidInputError` on EAN-13 | Non-numeric characters in data | EAN-13 only accepts digits 0–9 |
| `InvalidInputError` on Code 39 | Lowercase letters in base mode | Set `Code39Options(full_ascii=True)` |
| QR code too large | Version too low for data length | Let the library auto-select version, or increase `QrOptions.version` |
| UPC-E `InvalidInputError` | Data does not match the zero-suppression pattern | Verify 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 / Method | Description |
|----------------|-------------|
| `BarcodeService.generate(symbology, data, encode, render)` | Generate a barcode for any registered symbology |
| `Code128Options` | Encoding options for Code 128 (encode mode, GS1, ECI) |
| `Code128EncodeMode` | Enum: AUTO, CODE_A, CODE_B, CODE_C, CODE_AB, CODE_AC, CODE_BC |
| `Code39Options` | Encoding options for Code 39 (full ASCII, check digit) |
| `Code39EncodeMode` | Enum: BASE, FULL_ASCII |
| `Ean13Options` | Encoding options for EAN-13 (check digit input) |
| `Ean8Options` | Encoding options for EAN-8 (check digit input) |
| `QrOptions` | Encoding options for QR Code (error correction, version, mask, mode) |
| `QrEncodeMode` | Enum: AUTO, NUMERIC, ALPHANUMERIC, BYTE, KANJI |
| `QrErrorCorrectionLevel` | Enum: L, M, Q, H |
| `UpcaOptions` | Encoding options for UPC-A |
| `UpceOptions` | Encoding options for UPC-E |
| `SymbologyRegistry` | Resolves symbology names and provides definitions |

## See Also

- [Aspose.BarCode for Python — Enterprise Documentation](https://docs.aspose.com/barcode/python-net/)