User Rating 0.0
Total Usage 0 times
Supports printable ASCII: space through ~
Enter text and click Generate
Is this tool helpful?

Your feedback helps us improve.

About

Code 128 is a high-density linear barcode symbology defined in ISO/IEC 15417. Subset B encodes all standard ASCII characters from 32 (space) to 126 (tilde), making it the default choice for alphanumeric data in logistics labels, shipping manifests, and inventory systems. A malformed checksum or incorrect quiet zone renders the barcode unscannable. Retail scanners reject codes silently. This tool computes the mandatory modulo-103 check character and enforces the required quiet zones of at least 10x module width on each side. It approximates ideal print output assuming a thermal or laser printer at 203dpi or higher. Bar width below 0.19mm risks read failures on CCD scanners.

code 128 barcode generator code 128-b barcode creator 1d barcode linear barcode

Formulas

The Code 128-B check digit is computed as a weighted modular sum. The start character (value 104 for Subset B) is included at weight 1. Each subsequent data symbol is weighted by its ordinal position.

C = ( vstart + ni=1 i vi ) mod 103

Where C = check digit value, vstart = 104 (Start B code value), vi = symbol value of the i-th data character (ASCII code 32), and n = total number of data characters. The resulting check value maps to a symbol in the Code 128 table, appended before the Stop pattern.

Each symbol encodes into 11 modules (alternating black and white bars). The Stop symbol is a special 13-module pattern. Total barcode width in modules: W = 11 ( n + 3 ) + 2 + 2 Q, where the 3 accounts for Start, Check, and Stop (with Stop contributing 13 modules adjusted), and Q = quiet zone width in modules (minimum 10).

Reference Data

ValueCharacterPattern (B S B S B S)Encoding
0SP (space)2 1 2 2 2 211011001100
1!2 2 2 1 2 211001101100
2"2 2 2 2 2 111001100110
10*1 1 1 3 2 210111011000
1601 1 3 1 2 210110111000
1711 1 3 2 2 110110111100
26:1 2 1 1 2 311010010000
33A1 2 3 2 1 111010111100
34B1 2 3 1 1 211010111000
53U2 3 1 1 1 211100101100
65a1 1 2 1 3 210111101100
66b1 1 2 3 1 210111100110
80p2 1 1 2 1 311011000010
90z1 2 2 1 1 311010000110
94~2 1 2 1 1 311001000010
104Start B2 1 1 2 3 211010010000
106Stop2 3 3 1 1 1 21100011101011

Frequently Asked Questions

Subset B encodes ASCII characters 32 through 126, covering space, digits 0 - 9, uppercase A - Z, lowercase a - z, and all standard punctuation. Control characters (ASCII 0 - 31) require Subset A. For dense numeric-only data, Subset C packs two digits per symbol.
The scanner reads all symbols, recomputes the weighted sum modulo 103, and compares the result to the penultimate symbol (the check character). If they do not match, the scan is rejected. A single transposition or substitution error is always detected. The algorithm catches all single-character errors and most adjacent transpositions.
ISO/IEC 15417 specifies a minimum module width (X-dimension) of 0.19mm for open-system applications. Laser scanners tolerate smaller modules than CCD scanners. At 203dpi (standard thermal printers), one dot equals approximately 0.125mm, meaning at least 2 dots per module is recommended for print clarity.
Below the minimum X-dimension, ink spread (dot gain) on thermal or inkjet printers causes bars to merge. Additionally, quiet zones (blank margins flanking the barcode) must be at least 10 modules wide. If your label crops the margins, scanners cannot detect start/stop patterns. Increase bar width or verify your print DPI.
No. Subset B strictly covers values 0 - 94 (mapping ASCII 32 - 126). Characters above ASCII 126 are not representable. For binary data, consider Code 128 with FNC4 shift sequences or use a 2D symbology such as Data Matrix or QR Code.
Code 128-B is significantly denser. Code 39 uses a wide/narrow ratio and encodes each character in 13 modules (including inter-character gap), while Code 128-B uses 11 modules and supports all 95 printable ASCII characters versus Code 39's 43. Code 128-B also has a mandatory checksum, whereas Code 39's check digit is optional.