ZPL ^BY Command Examples for Code 128 and GS1-128 Labels
The ZPL ^BY command is small, easy to overlook, and responsible for many barcode readability problems. It sets barcode defaults such as module width, wide-to-narrow ratio, and height. When teams copy a barcode block between label sizes or printer densities, ^BY is often the command that should have been reviewed first.
The basic shape
^BYw,r,h
wis the module width in dots.ris the wide-to-narrow ratio for supported barcode types.his the default barcode height in dots.
Not every barcode command uses every value in the same way, but ^BY remains the first knob to check for Code 128 labels.
A compact Code 128 example
^XA
^PW812
^LL406
^FO50,50^A0N,32,32^FDOrder 100245^FS
^FO50,110^BY2,2,90
^BCN,90,Y,N,N
^FDORD100245^FS
^XZ
This version is compact and can work well for internal labels. For shipping labels, the same barcode may be too dense if the printer is running fast or the scanner is old.
A more forgiving shipping label barcode
^XA
^PW812
^LL1218
^FO60,80^A0N,42,42^FDTracking^FS
^FO60,150^BY3,2,140
^BCN,140,Y,N,N
^FD1Z999AA10123456784^FS
^XZ
Moving from ^BY2 to ^BY3 makes the symbol wider, but it often improves real-world scanning. Preview the result in ZPL Viewer and confirm it still fits within the label width.
GS1-128 needs data discipline
GS1-128 is not just “Code 128 with parentheses.” The human-readable string may show application identifiers like (01) and (17), but the encoded data must follow GS1 rules. Variable-length fields need separators in the right places, and scanners must be configured to interpret the data.
^XA
^CI28
^FO50,40^A0N,32,32^FDGS1-128 Example^FS
^FO50,100^BY2,2,120
^BCN,120,Y,N,N
^FD>;>8010950110153000317260515>810LOT42>821SN10001^FS
^FO50,260^A0N,24,24^FD(01)09501101530003(17)260515(10)LOT42(21)SN10001^FS
^XZ
Use the GS1 Helper to create a starter snippet, then validate using the same scanner and software that will receive the data in production.
Common mistakes
- Using
^BY1because the barcode looks neat on screen. - Scaling coordinates for 300 DPI but leaving barcode height unchanged.
- Putting a border too close to the left or right quiet zone.
- Showing human-readable GS1 text but encoding a different value.
- Testing only with a phone camera instead of the warehouse scanner.
For template reviews, compare the old and new barcode blocks with ZPL Diff. A one-character change in barcode data can be harder to spot than a moved field.
