Code 128 Explained

Code 128 is the most widely deployed linear barcode in the world. It appears on shipping cartons, warehouse bin labels, hospital wristbands, airline boarding passes, and millions of inventory labels. Understanding how it works helps you use it correctly — and avoid the formatting and size mistakes that cause scan failures.

History and Standardisation

Code 128 was developed by Computer Identics Corporation in 1981. It was designed to address the limitations of earlier symbologies — particularly Code 39's limited character set and lower density. Code 128 encodes the full ASCII character set (128 characters, matching its name) and achieves roughly twice the data density of Code 39 for alphanumeric data. It was standardised as ISO/IEC 15417 in 2007.

The Three Subsets

Code 128 is unique in having three encoding subsets that can be mixed within a single symbol:

Subset A encodes uppercase letters (A–Z), digits (0–9), control characters (NUL, SOH, STX, etc.), and a limited set of punctuation. It is used when control characters must be encoded — uncommon in label printing.

Subset B encodes the full printable ASCII character set: uppercase and lowercase letters, digits, and punctuation. It is the most commonly used subset for inventory and asset labels with alphanumeric SKUs.

Subset C encodes digits only, two per encoded character. This doubles the data density: 10 numeric digits in the same physical width as 5 alphanumeric characters in Subset B. Use Subset C for numeric-only data (pure numeric SKUs, SSCC numbers in GS1-128) to produce the most compact barcode possible.

A smart encoder switches between subsets mid-symbol to optimise density. For a value like LOT123456789, the encoder uses Subset B for "LOT" and switches to Subset C for the nine-digit number. This automatic optimisation is what makes Code 128 more efficient than older symbologies for mixed-content data.

The Checksum Algorithm

Every Code 128 symbol includes a check character calculated from the data. The algorithm: multiply the value of each character by its position index (starting from 1 for the first data character), sum all products, add the start character value, and take the result modulo 103. The modulo result is the check character, appended before the stop pattern. Most barcode generators compute this automatically. The check character is not human-readable and does not appear in the decoded string.

GS1-128: Code 128 With Application Identifiers

GS1-128 is an application of Code 128 that uses GS1-standardised Application Identifiers (AIs) to specify data meaning. AIs are numeric prefixes in parentheses: (01) GTIN, (10) lot/batch number, (17) expiry date (YYMMDD), (21) serial number, (30) count, and many more. A single GS1-128 symbol can carry multiple AI-value pairs concatenated. GS1-128 is mandatory on shipping cartons, pallets, and inner packs in most major retail supply chains. If you are shipping to a grocery, pharmacy, or big-box retailer, their routing guide will specify GS1-128.

Minimum Sizes and Print Requirements

There is no GS1-mandated minimum size for Code 128 in non-retail applications (unlike UPC-A and EAN-13). The practical minimum depends on your printer resolution and scanner. At 300 DPI laser printing, a Code 128 barcode is readable with a bar height of 5 mm for close-range (under 30 cm) scanning. For warehouse scanners at 1 metre, 10–15 mm bar height is a safe minimum. For forklift-mounted scanners at 3 metres, 30 mm or taller.

The quiet zone for Code 128 is 10× the narrow bar width on each side. At standard 300 DPI printing with a 0.33 mm narrow bar, the quiet zone is about 3.3 mm per side. Use the print size guide to calculate dimensions for your specific setup.

Industries That Use Code 128

  • Logistics and shipping: GS1-128 on all cartons and pallets
  • Retail supply chain: GS1-128 for supplier compliance
  • Healthcare: GS1-128 on drug packaging (FDA drug traceability rule)
  • Airline industry: boarding passes (Code 128 and PDF417)
  • Manufacturing: work order tracking, component serialisation
  • General inventory: warehouse, library, food production

Frequently Asked Questions

How many characters can Code 128 encode?

There is no strict maximum — the barcode grows wider with more data. In practice, a readable label can hold 20–60 characters before the symbol becomes unwieldy. For very long data (over 50 characters), consider a 2D symbology like QR code or DataMatrix.

Does Code 128 support lowercase letters?

Yes — Subset B encodes the full printable ASCII set including lowercase. Subset A only encodes uppercase. For labels with mixed case (e.g., product descriptions), the encoder uses Subset B.

What is the difference between Code 128 and GS1-128?

All GS1-128 is Code 128, but not all Code 128 is GS1-128. GS1-128 adds the FNC1 character at the start of the symbol and follows GS1's Application Identifier structure. Plain Code 128 has no such requirement.

Should I use Code 128 or Code 39 for my inventory?

Code 128. It supports more characters, produces smaller barcodes for the same data, and is supported by all modern scanners. Use Code 39 only when a specification (government contract, healthcare standard, trading partner requirement) mandates it.

Generate labels right now — free

The free tool runs entirely in your browser. No account, no uploads.

    More small-business tools: PromptedPaperwork