Saltar al contenido

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 visor

Generador

Generando…

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ámetroQué haceValores
^BY wModule width: the narrowest bar, in dots1 to 10; default 2
^BY hDefault bar height, in dotsdefault 10
^BC oOrientaciónN, R (90°), I (180°), B (270°)
^BC hBar height, in dotsoverrides the ^BY height
^BC fPrint the human-readable lineY or N
^BC gPrint that line above the barsY or N
^BC eUCC check digitY or N
^BC mModeN none, U UCC case, A automatic, D UCC/EAN (GS1-128)
Code 128 barcode for OZ-2026-0042 with the text under the bars
etiqueta de 4 × 2 in a 203 dpi (8 dpmm) · 812 × 406 px · Abrir en el visor
^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

Code 128 of the digits 001048200001 encoded one by one, 334 dots wide
etiqueta de 4 × 2 in a 203 dpi (8 dpmm) · 812 × 406 px · Abrir en el visor
^XA
^BY2,3,120
^FO60,60^BCN,120,Y,N,N,N
^FD001048200001^FS
^XZ

Starting with >; (subset C): 202 dots wide

The same digits in Code 128 subset C, 202 dots wide
etiqueta de 4 × 2 in a 203 dpi (8 dpmm) · 812 × 406 px · Abrir en el visor
^XA
^BY2,3,120
^FO60,60^BCN,120,Y,N,N
^FD>;001048200001^FS
^XZ
Code in ^FDEffect
>;Start in subset C (pairs of digits)
>:Start in subset B
>9Start in subset A
>8FNC1, 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.

GS1-128 barcode with a GTIN and a batch number, brackets shown in the text line
etiqueta de 4 × 2 in a 203 dpi (8 dpmm) · 812 × 406 px · Abrir en el visor
^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.

Fuentes