Code 128-B Generator
Generate Code 128 Barcode Subset B from text. Renders scannable barcodes with checksum validation, PNG download, and print support.
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.
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.
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
| Value | Character | Pattern (B S B S B S) | Encoding |
|---|---|---|---|
| 0 | SP (space) | 2 1 2 2 2 2 | 11011001100 |
| 1 | ! | 2 2 2 1 2 2 | 11001101100 |
| 2 | " | 2 2 2 2 2 1 | 11001100110 |
| 10 | * | 1 1 1 3 2 2 | 10111011000 |
| 16 | 0 | 1 1 3 1 2 2 | 10110111000 |
| 17 | 1 | 1 1 3 2 2 1 | 10110111100 |
| 26 | : | 1 2 1 1 2 3 | 11010010000 |
| 33 | A | 1 2 3 2 1 1 | 11010111100 |
| 34 | B | 1 2 3 1 1 2 | 11010111000 |
| 53 | U | 2 3 1 1 1 2 | 11100101100 |
| 65 | a | 1 1 2 1 3 2 | 10111101100 |
| 66 | b | 1 1 2 3 1 2 | 10111100110 |
| 80 | p | 2 1 1 2 1 3 | 11011000010 |
| 90 | z | 1 2 2 1 1 3 | 11010000110 |
| 94 | ~ | 2 1 2 1 1 3 | 11001000010 |
| 104 | Start B | 2 1 1 2 3 2 | 11010010000 |
| 106 | Stop | 2 3 3 1 1 1 2 | 1100011101011 |