Skip to content
StylQR home
Barcode Guides

Code 128 vs Code 39: Which Barcode Should You Use?

Code 128 vs Code 39 compared: character sets, check digits, how much space each takes, scanner support, and which one to pick for labels, assets and badges.

By StylQR Editorial TeamPublished 5 min read

StylQR blog cover: Code 128 vs Code 39: Which Barcode Should You Use?, illustrated with two barcodes compared with letters and numbers on a teal background
Table of contents

For most new labels, Code 128 is the better choice. It encodes all 128 ASCII characters, always includes a check character, and takes up far less width for the same data. Code 39 is worth using when a customer, industry standard or older system specifically asks for it, because it's simpler and almost every scanner reads it by default.

Here's how they differ in detail, with real width comparisons and the check calculations for each.

At a glance

Code 39Code 128
StandardISO/IEC 16388ISO/IEC 15417
Introduced1974, Intermec1981, Computer Identics
Characters43: A to Z, 0 to 9, space and - . $ / + %All 128 ASCII characters
LowercaseOnly via Full ASCII pairsYes, natively
Check characterOptional (mod 43)Mandatory (mod 103)
Width per character13 to 16 modules, including the gap11 modules; digits in pairs
Start and stop* at each endStart A, B or C, plus a 13-module stop
Typical useAutomotive, defence, ID badges, older systemsShipping, warehousing, asset tags, healthcare

How Code 39 works

Each Code 39 character is nine elements, five bars and four spaces, and exactly three of the nine are wide. That's where the full name "Code 3 of 9" comes from. Characters are separated by a narrow gap, and the whole symbol starts and ends with an asterisk, so PART-42 is encoded as *PART-42*.

Because every character carries its own fixed pattern of wide and narrow elements, Code 39 is self-checking: a single printing defect rarely turns one valid character into another. That's why the check character is optional.

When you do want one, it's a simple mod 43 sum. Each character has a value (0 to 9 are 0 to 9, A to Z are 10 to 35, then - is 36, . 37, space 38, $ 39, / 40, + 41, % 42). For ABC: 10 + 11 + 12 = 33, and 33 divided by 43 leaves 33, which is the letter X. The encoded data becomes ABCX. The scanner must be told to expect it.

Full ASCII Code 39

To get lowercase and extra symbols, Full ASCII mode writes them as two-character pairs using $, %, / and +. It works, but it doubles the width of those characters, and a scanner not set to Full ASCII will output the raw pairs.

How Code 128 works

Each Code 128 character is 11 modules wide, made of three bars and three spaces. There are three code sets:

  • Code set A: uppercase, digits, punctuation and control characters (like tab and carriage return).
  • Code set B: uppercase, lowercase, digits and punctuation. The usual choice for text.
  • Code set C: pairs of digits from 00 to 99, so each 11-module character carries two digits.

A barcode can switch sets mid-way. Good generators pick the shortest combination automatically, using set C for runs of digits.

The check character is mandatory. It's a weighted sum: the start code's value, plus each data character's value multiplied by its position, all divided by 103, keeping the remainder. For 123456 in set C, the values are 12, 34 and 56 with start C worth 105:

  1. 105 + (12 × 1) + (34 × 2) + (56 × 3) = 105 + 12 + 68 + 168 = 353.
  2. 353 divided by 103 is 3 remainder 44.
  3. The check character is the one with value 44.

The scanner checks this and won't output a misread, which is a big part of why Code 128 has a reputation for reliability.

The width difference in practice

Width is where Code 128 wins clearly. Counting modules (X), assuming a 3:1 wide-to-narrow ratio for Code 39:

DataCode 39 widthCode 128 width
ABC123127X101X (set B)
123456127X68X (set C)
00012345678 (11 digits)207X112X (mostly set C)

Those figures exclude quiet zones. At an X-dimension of 0.33 mm, the 11-digit example is about 68 mm wide in Code 39 and about 37 mm in Code 128. On a small label, that decides whether the code fits at a scannable size at all.

Which one should you pick?

Pick Code 128 when:

  • You're designing a new labeling scheme and nobody has mandated a format.
  • Data includes lowercase letters or is mostly numeric.
  • Space is tight, or the data is longer than about 10 characters.
  • You'll later need GS1-128 for shipping labels; your scanners and printers will already support it.

Pick Code 39 when:

  • A customer, auditor or standard requires it. Some automotive and defence labeling specifications are built on Code 39.
  • You're matching existing labels in a system that expects it.
  • You want people to be able to type the content using a basic barcode font, with only uppercase and digits.
Note: Neither is a retail product barcode. For goods sold in shops, use EAN-13 or UPC-A with a GS1 number. Types of barcodes maps out which format belongs where.

Printing tips for both

  • Keep a quiet zone of at least 10 modules on each side. It's the most common cause of no-reads on homemade labels.
  • Print at a resolution that matches the module width. On a 203 dpi thermal printer, one dot is about 0.125 mm, so choose an X-dimension that's a whole number of dots.
  • Dark bars on a light background. Red bars are invisible to red-light scanners.
  • Test with the scanner you'll actually use, from the distance it will be used at.

Making either barcode

The Code 128 generator includes the mandatory mod 103 check character for you. The Code 39 generator checks your text against the allowed characters as you type. Both let you set bar width and height in millimeters and download SVG, PNG at up to 1200 DPI, or an exact-size PDF. For a complete walk-through, see how to generate barcodes online for free, and if you're labeling a lot of items, how to generate multiple barcodes at once covers bulk output. If you'd rather store more data in less space, 1D vs 2D barcodes explains when a Data Matrix makes more sense.

Frequently asked questions

Can a Code 39 barcode contain lowercase letters?

Only in Full ASCII mode, where each lowercase letter is written as a pair such as +A for a. The scanner must have Full ASCII mode turned on, otherwise it shows the pairs literally.

Is Code 128 the same as GS1-128?

GS1-128 is Code 128 with an FNC1 character after the start code and data structured with GS1 Application Identifiers. Every GS1-128 is a valid Code 128, but not the other way round.

Why does my Code 39 scan show asterisks?

Some fonts and generators expect you to type the asterisks yourself, and some scanners are set to transmit the start and stop characters. Remove them from the data or change the scanner setting.

Can I use Code 128 on retail products instead of a UPC?

No. Checkouts expect an EAN-13 or UPC-A carrying a GS1 GTIN. Code 128 is for internal and logistics labels.

Share this guide

StylQR blog cover: How to Create a Barcode for Your Products, illustrated with a product box with a barcode, a price tag and a certificate on a teal background

Barcode Guides

How to Create a Barcode for Your Products

Create product barcodes the right way: license GTINs from GS1, assign one per variant, pick EAN-13 or UPC-A, size and place the code, then print and test it.

· 5 min read

StylQR blog cover: How to Generate Barcodes Online for Free, illustrated with a barcode with a desktop screen, a download arrow and a gift on a ocean background

Barcode Guides

How to Generate Barcodes Online for Free

Make a barcode online for free: pick the right type, enter valid data, set the bar width in mm, keep the quiet zone, and download print-ready SVG, PNG or PDF.

· 5 min read