Code 128 barcodes in ZPL with ^BC
To print a Code 128 barcode in ZPL, set the module width and height with ^BY, then use ^BCN and the data: ^BY2,3,120^FO60,60^BCN,120,Y,N,N^FDOZ-2026-0042^FS. Code 128 encodes all 128 ASCII characters and packs digits in pairs, which makes it the usual choice for shipping and inventory labels.
Actualizado 2026-10-20 · Renderizados hechos con el motor de OpenZPL
Abrir en el visorGenerador
Etiqueta de 4 × 2 pulgadas a 203 dpi. Una vista previa muestra cómo la impresora dibuja el código; confirme con un escáner antes de imprimir una serie.
The ^BC command
| Parámetro | Qué hace | Valores |
|---|---|---|
^BY w | Module width: the narrowest bar, in dots | 1 to 10; default 2 |
^BY h | Default bar height, in dots | default 10 |
^BC o | Orientación | N, R (90°), I (180°), B (270°) |
^BC h | Bar height, in dots | overrides the ^BY height |
^BC f | Print the human-readable line | Y or N |
^BC g | Print that line above the bars | Y or N |
^BC e | UCC check digit | Y or N |
^BC m | Mode | N none, U UCC case, A automatic, D UCC/EAN (GS1-128) |

^XA ^BY2,3,120 ^FO60,60^BCN,120,Y,N,N ^FDOZ-2026-0042^FS ^XZ
Width in dots
The width depends on the data and the module width. OZ-2026-0042 measures 334 dots at ^BY2 and 501 dots at ^BY3 (42 mm and 63 mm at 203 dpi). Never use a module width of 1 at 203 dpi unless you have checked that your scanner reads it.
Subsets and digits
Code 128 has three subsets: A (capitals and control characters), B (capitals and lower case) and C (digits, two per symbol). In mode N the printer follows your data as written, so digits are encoded one by one. Start the data with >; to switch to subset C, or use mode A to let the printer choose. Both make a numeric code much shorter:
Mode N: 334 dots wide

^XA ^BY2,3,120 ^FO60,60^BCN,120,Y,N,N,N ^FD001048200001^FS ^XZ
Starting with >; (subset C): 202 dots wide

^XA ^BY2,3,120 ^FO60,60^BCN,120,Y,N,N ^FD>;001048200001^FS ^XZ
Code in ^FD | Effect |
|---|---|
>; | Start in subset C (pairs of digits) |
>: | Start in subset B |
>9 | Start in subset A |
>8 | FNC1, used by GS1-128 |
GS1-128
Mode D writes a GS1-128 code: the data is a series of application identifiers in brackets, such as (01) for the GTIN and (10) for the batch. The printer removes the brackets from the bars, adds the FNC1 characters and keeps the brackets in the human-readable line. The example below decodes as a GS1 symbol (]C1). The meaning and length of each identifier are defined by GS1; check them before printing logistics labels.

^XA ^BY2,3,120 ^FO40,60^BCN,120,Y,N,N,D ^FD(01)09501101530003(10)ABC123^FS ^XZ
Invalid data
Code 128 accepts any ASCII character, so most data is valid. The exceptions are the ZPL control characters: ^ and ~ end the field instead of being printed. Escape them with ^FH; see special characters in data. Characters beyond ASCII, such as é, are not part of Code 128.
Verifique un código de barras antes de imprimir una tanda
Una vista previa muestra cómo la impresora dibujará el código: anchos de barras, zona muerta y la línea legible por humanos. No prueba que cada escáner lo lea en su medio. Imprima una etiqueta a la densidad real y escáneela con el escáner que utiliza su cliente o transportista; para códigos de venta al por menor y logística, un verificador de códigos de barras califica la calidad de impresión.
Preguntas
How do I make a Code 128 barcode shorter?
Lower the module width in ^BY, or for numeric data start the field with >; (or use mode A) so digits are packed in pairs.
How do I hide the text under the barcode?
Set the third parameter of ^BC to N: ^BCN,120,N,N,N.