Code 128 vs Code 39 for labels and inventory
Code 128 vs Code 39 measured on the same data: widths, check characters and character sets, so you can pick the right barcode for stock labels and bins.
Use Code 128 unless something forces Code 39. For the same data it came out between 4 and 55 per cent shorter in our tests, it takes lower case, and it carries a check character in every symbol. Code 39 earns its place only when a customer, a standard or an old scanner names it. That is the whole answer to code 128 vs code 39 for most shops and stockrooms. The rest of this page shows the measurements behind it, so you can see where the gap is large and where it nearly disappears.
If you are still choosing between barcode families, the overview in barcodes explained covers where both sit. This page is only about internal labels, where you choose the content yourself.
The same data, five ways
We encoded five strings with JsBarcode 3.12.3, the library inside our barcode maker, and counted the modules, the width of the narrowest bar, from the first bar to the last. Quiet zones are not included. Code 39 has no single fixed ratio between wide and narrow bars: the range runs from 2.0 to 3.0, with 2.5 recommended. JsBarcode draws it at 3:1, so we give the 2:1 result as well, worked out the same way.
| Data | Characters | Code 128 | Code 39 at 3:1 | Code 39 at 2:1 |
|---|---|---|---|---|
590123412345 |
12 digits | 101 | 224 | 182 |
12345678 |
8 digits | 79 | 160 | 130 |
SKU-4471 |
8, letters and digits | 112 | 160 | 130 |
SKU-2026-0042 |
13, letters and digits | 167 | 240 | 195 |
BOX 117 |
7, letters and digits | 112 | 144 | 117 |
Digits are where Code 128 pulls away. Twelve digits take 101 modules in Code 128 and 224 in Code 39 at 3:1, which at an illustrative 0.3 mm per module is about 30 mm against 67 mm of bars. On a 50 mm label that decides whether the code fits at all. For mixed text the gap narrows to roughly a third at 3:1, and for a short string like BOX 117 set at 2:1 the two are within five modules of each other. If your labels are short, uppercase and have room to spare, Code 39 costs you almost nothing in width. That is not a reason to pick it. It is a reason not to worry if you inherit it.
Why Code 128 is shorter
Two design choices explain the table.
Code 128 makes every symbol 11 modules wide and ends with a 13-module stop pattern. Seagull’s notes describe each character as three bars and three spaces, and they list a start character, the data, a check character and the stop. There are three code sets. Set C holds all digit pairs from 00 to 99, so one symbol stands for two digits. Their summary: “Code 128 gives you the greatest possible character density when encoding data.”
The 12-digit number works out as arithmetic:
Start C 1 symbol
6 digit pairs 6 symbols (59 01 23 41 23 45)
Check 1 symbol
8 symbols x 11 modules = 88
Stop pattern = 13
Total = 101 modules
Code 39 makes each character nine elements, five bars and four spaces, with exactly three of them wide. At 3:1 that is 3 x 3 + 6 = 15 modules, plus one module of gap, 16 per character. The start and stop are asterisks, and they count as characters. Twelve digits plus two asterisks is 14 characters, and 14 x 16 = 224. Nothing in Code 39 packs two digits into one symbol, so numeric data pays full price.
The encoder also changes subsets on its own. SKU-4471 begins with letters, so it starts in set B, then drops into set C for 4471:
Start B, S, K, U, -, Code C, 44, 71, check
= 9 symbols x 11 + 13 = 112 modules
Forced into set B throughout, the same text would take 10 symbols and 123 modules. The automatic switch saved 11. Our maker’s Code 128 option does it for you.
The check character, calculated by hand
Code 128’s check character is mandatory. Seagull says it is based on the modulo 103 algorithm and sits just before the stop pattern. You can verify one yourself. Each symbol has a value: the start code B is 104, and in set B each character is worth its ASCII number minus 32. Multiply each value after the start by its position, add everything, divide by 103, and the remainder is the check value.
Symbol Value Position Product
Start B 104 - 104
S 51 1 51
K 43 2 86
U 53 3 159
- 13 4 52
Code C 99 5 495
44 44 6 264
71 71 7 497
----
Sum 1708
1708 / 103 = 16 remainder 60, so the check symbol has value 60
We decoded the bars JsBarcode produced for SKU-4471 and the last symbol before the stop is 60. The arithmetic and the library agree.
Code 39’s check character is optional. Seagull’s Full ASCII page describes an optional modulo 43 check and says the start and stop characters are left out of the calculation. Digits are worth 0 to 9, A to Z are worth 10 to 35, and the symbols are 36 to 42. For CODE39: C 12, O 24, D 13, E 14, 3 and 9 add to 75, and 75 mod 43 is 32, which is W. Writing it as CODE39W is a convention your scanner and software must both expect. Our maker draws Code 39 without the check character, so a reader set to demand one would reject its output.
What each one can hold
Code 39 is the smaller alphabet: capital letters, digits, the space and - . $ / + %, 43 characters in all. Our maker accepts up to 43 of them and converts anything you type to capitals. Code 128 can express all 128 ASCII characters, upper and lower case and punctuation included, and the maker accepts up to 80.
Code 39 does have an Extended form that reaches lower case by pairing characters, so a lower-case letter is written as + followed by the capital. The catch is on the reading side. Seagull notes that the scanner must be set to Full ASCII mode. A reader left in the default mode will hand your software +A where you meant a, and the label will look perfect while the data is wrong. Code 128 avoids that trap entirely.
Scanners, standards and habit
We cannot test your scanner, and nobody else can from here. Both codes are decades old. Dynamsoft’s comparison dates Code 39 to 1974 and Code 128 to 1981, and it names the US Department of Defense’s LOGMARS standard as a reason some organisations are bound to Code 39. If a customer’s purchase order or a government specification says Code 39, use it, whatever the width.
Scanners normally drop the asterisks and send only the data between them. If your system suddenly shows *SKU* around values, a reader setting is transmitting start and stop characters. That is a scanner configuration problem, not a barcode problem.
For shipping, the choice is usually made for you. GS1 India’s guidance names GS1-128 or ITF-14 for shipping cartons and pallets. GS1-128 is a structured form of Code 128, so a Code 128 habit carries over. Retail packs are different again: they need an EAN-13 or UPC-A, not either of these. If you need that kind of code and have no number, read how to get a barcode for your product in India.
When the code is too wide for the label
A barcode that runs off the label is the usual trigger for this whole comparison, and there are three fixes in order of cost. First, switch to Code 128 if you are on Code 39, which on digit-heavy data takes about half the width. Second, shorten the data: SKU-2026-0042 (167 modules) to 2026-42 (101) is a third off. Third, reduce the bar thickness slider in the maker from 2 to 1, but only if your printer can lay down a single-module bar cleanly. Test that on paper first. A thermal printer that smudges one-module bars will turn a fixed fit into an unreadable label.
Shrinking the whole picture evenly works until the narrowest bar is thinner than your printer can draw cleanly. Cropping the ends or squashing only part of the code does not work at all, because the margin and every bar width are part of the data.
Pick like this
- New labels for your own stock, bins, parcels or returns: Code 128. Digits and mixed text are shorter, the check character is built in, and nothing breaks on lower case.
- A customer or standard that names Code 39: Code 39, uppercase only, and ask whether they want the mod 43 check character.
- Short uppercase IDs on large labels, replacing an old system slowly: either works. Keep what the scanners already read.
- Digits only, narrow label: Code 128, because set C halves the symbol count.
Make a sample in the barcode maker, print it at the size you plan to use, and scan it with the actual device before you order 5,000 labels.
Ready to try it? Free, no sign-up, made in your browser.
Open the barcode maker