Pular para o conteúdo

Code 39 barcodes in ZPL with ^B3

To print a Code 39 barcode in ZPL, set ^BY and use ^B3N: ^BY2,3,120^FO60,60^B3N,N,120,Y,N^FDOZ-0042^FS. Code 39 accepts digits, capital letters, space and - . $ / + %, and is wider than Code 128 for the same data.

Atualizado 2026-10-20 · Renders made with the OpenZPL engine

Open in the viewer

Generator

Renderizando…

4 × 2 in label at 203 dpi. A preview shows how the printer draws the code; confirm with a scanner before printing a run.

The ^B3 command

ParâmetroO que fazValores
^BY w, rModule width and wide-to-narrow ratio^BY2,3: 2 dots, ratio 3
^B3 oOrientationN, R, I, B
^B3 eMod-43 check digitY or N
^B3 hBar height, in dotsfor example 120
^B3 fPrint the human-readable lineY or N
^B3 gPrint that line above the barsY or N
Code 39 barcode for OZ-0042 with *OZ-0042* printed under it
4 × 2 in label at 203 dpi (8 dpmm) · 812 × 406 px · Open in the viewer
^XA
^BY2,3,120
^FO60,60^B3N,N,120,Y,N
^FDOZ-0042^FS
^XZ

The human-readable line shows the asterisks that start and stop every Code 39 symbol; they are not part of the data. The ratio changes the width: OZ-0042 measures 286 dots at ^BY2,3 and 232 dots at ^BY2,2.

^BY2,2: 232 dots

The same Code 39 with a wide-to-narrow ratio of 2, narrower
4 × 2 in label at 203 dpi (8 dpmm) · 812 × 406 px · Open in the viewer
^XA
^BY2,2,120
^FO60,60^B3N,N,120,Y,N
^FDOZ-0042^FS
^XZ

^BY2,3: 286 dots

Code 39 barcode for OZ-0042 with *OZ-0042* printed under it
4 × 2 in label at 203 dpi (8 dpmm) · 812 × 406 px · Open in the viewer
^XA
^BY2,3,120
^FO60,60^B3N,N,120,Y,N
^FDOZ-0042^FS
^XZ

Valid and invalid data

DataResult in the OpenZPL engine
OZ-0042Valid
oz-0042Drawn as OZ-0042: lower case is printed as capitals
OZ_0042Not drawn: the API answers 400 Bad Request with ERROR: Code 39: invalid character '_'

If you need lower case or symbols such as _, use Code 128, which encodes all of ASCII in less space.

The mod-43 check digit (^B3N,Y,…) is not added by the OpenZPL engine yet: the code renders without it. If your scanner requires it, check the result on the printer; see compatibility.

Check a barcode before printing a run

A preview shows how the printer will draw the code: bar widths, quiet zone and the human-readable line. It does not prove that every scanner reads it on your media. Print one label at the real density and scan it with the scanner your customer or carrier uses; for retail and logistics codes, a barcode verifier grades the print quality.

Perguntas

Code 39 or Code 128?

Code 128 for new labels: it is shorter and takes any ASCII character. Code 39 stays where a customer or an older system requires it.

Why are there asterisks under my Code 39 barcode?

They are the start and stop characters, printed in the human-readable line by convention. Scanners don't return them.

Sources