Skip to content
ScanHatch

Barcodes

What Is Code 128? Character Sets, Check Characters and GS1-128

By ScanHatch · Published · 4 min read

Code 128 is the workhorse of shipping labels, warehouse systems and asset tags. It can encode any standard keyboard character, and it's one of the most compact linear barcodes available. Here's how it manages both, and how its GS1-128 variant carries structured supply-chain data.

The structure of a Code 128 barcode

Code 128 was introduced in 1981 and is standardised as ISO/IEC 15417. Every symbol character is 11 modules wide, made of three bars and three spaces, each 1 to 4 modules wide. The name comes from its ability to encode all 128 ASCII characters. A barcode is:

  1. A quiet zone of at least 10 modules.
  2. A start character, which also selects the first character set (A, B or C).
  3. The data characters.
  4. A check character.
  5. A stop pattern (13 modules), and another quiet zone.

Character sets A, B and C

Code 128 character sets
SetContainsUseful for
ACapital letters, digits, punctuation and control characters (such as tab)Uppercase data with control codes
BCapital and lowercase letters, digits and punctuationOrdinary text
CThe 100 digit pairs 00 to 99Numbers: two digits per character

Special shift and code-change characters let a barcode switch sets partway through, so a value like ABC123456 can be letters in set B followed by digit pairs in set C. Good encoders, including the one ScanHatch uses, choose the switches that give the shortest result, so you never need to pick a set yourself.

Why numbers make shorter barcodes

Set C packs two digits into each 11-module character. That makes numeric data about half as wide as text of the same length:

Width of Code 128 barcodes (without quiet zones), measured with the ScanHatch encoder
DataCharacters usedWidth
ABCDEFStart B, 6 letters, check, stop101 modules
123456Start C, 3 digit pairs, check, stop68 modules
12345678901234Start C, 7 digit pairs, check, stop112 modules

Fourteen digits take barely more room than six letters. This is why Code 128 is preferred over Code 39 for long numeric IDs.

The mod 103 check character

Every Code 128 barcode has a check character. Its value is the start character's value plus each data character's value multiplied by its position, divided by 103; the remainder is the check value. For ABC in set B: 104 + 33×1 + 34×2 + 35×3 = 310, and 310 mod 103 = 1. Scanners verify it and then drop it, so you never see it in the scanned text. Barcode check digits explained compares it with other methods.

GS1-128: Code 128 with a data structure

GS1-128 is Code 128 with a special function character (FNC1) straight after the start, followed by data in Application Identifier (AI) format. Each AI is a number in brackets that says what the following data means. Common ones:

Some common GS1 Application Identifiers
AIMeaningFormat
(00)SSCC: serial number for a pallet or shipment18 digits
(01)GTIN of the trade item14 digits
(10)Batch or lot numberUp to 20 characters
(17)Expiry dateYYMMDD

Example (fictional data)

(01)15012345678907(17)271231(10)LOT42 means GTIN 15012345678907, expiring 31 December 2027, batch LOT42. The brackets are printed in the human-readable text but aren't encoded in the bars.

ScanHatch generates standard Code 128, not GS1-128. A GS1-128 label needs the FNC1 character and correct AI formatting, and retailers' logistics systems reject labels that get them wrong.

When to choose Code 128

  • Internal IDs: stock locations, asset tags, document and sample tracking.
  • Mixed letters and numbers, including lowercase, which Code 39 can't encode.
  • Long numeric IDs, where set C keeps the barcode short.
  • Not for retail products (use EAN-13 or UPC-A) and not for non-English characters, which scanners don't handle reliably.

Printing tips

  • Keep 10 modules of blank space at each end.
  • Bars should be at least 15% as tall as the barcode is long, and not less than about 6 mm, so handheld scanners can hit them.
  • Beyond about 20 to 30 characters the barcode gets long; consider a 2D code such as Data Matrix instead.

Create one with the Code 128 generator, or many at once from a spreadsheet with the Bulk Barcode Generator.

Frequently asked questions

Is Code 128 better than Code 39?

For most new uses, yes. It's more compact, supports lowercase, and always has a check character. Code 39 remains where existing systems require it.

Do I need to choose set A, B or C?

No. The encoder selects and switches sets automatically for the shortest barcode.

Is GS1-128 the same as Code 128?

GS1-128 is Code 128 with an FNC1 character and GS1 Application Identifiers. Every GS1-128 is a Code 128, but not the other way round.