^BY Bar Code Field Default

Sets the default bar width, width-to-narrow ratio, and height for all barcode fields that follow.

Supported in ZPL Preview

^BY sets default parameters for barcode commands that appear after it in the same format. Instead of specifying bar width and height on every individual barcode command, you set them once with ^BY and all subsequent barcodes inherit those values.

The three parameters control: module width (w — the width of the narrowest bar element, in dots), wide-to-narrow ratio (r — the ratio of the wide bar to the narrow bar), and bar height (h — the height of the barcode in dots).

Module width directly affects barcode density and scannability. At 203 DPI, a module width of 2 dots (≈10 mil) is typical for general-purpose labels. Width of 3 dots is easier to scan but larger; 1 dot is very small and may not scan reliably.

The wide-to-narrow ratio (r) applies only to 1D barcodes that use two distinct bar widths (like Code 39). Code 128 ignores this parameter. Ratio 3.0 is the default and standard; values between 2.0 and 3.0 work on most scanners.

^BY applies to all barcode commands that follow within the format, until overridden by another ^BY. Placing it once at the top of the format standardizes all barcodes.

Syntax

^BYw,r,h

Parameters

ParameterTypeDefaultDescription
winteger (1–10)2Module width — the width of the narrowest bar element in dots.
rdecimal (2.0–3.0)3.0Wide bar to narrow bar ratio. Only affects barcodes with two distinct bar widths (e.g., Code 39).
hinteger10Default barcode height in dots.

Examples

Set defaults for a standard shipping label barcode

Try in Viewer
^XA
^BY2,3,80
^FO50,50^BCN,80,Y,N,N^FD123456789012^FS
^XZ

Wide module for easy scanning

Try in Viewer
^XA
^BY3,3,100
^FO30,30^B3N,N,100,Y,N^FDABC-12345^FS
^XZ

Common Mistakes

  • !Omitting ^BY before barcode commands — barcode commands then fall back to firmware defaults, which vary by printer.
  • !Setting module width (w) to 1 on a 203 DPI printer — at 5 mil per dot, 1-dot bars are at the scanner's reliability limit.
  • !Thinking ^BY affects text fields — it only modifies barcode commands.
  • !Placing ^BY after the barcode command — it only affects commands that come after it.
^BY Bar Code Field Default — ZPL Command Reference | Prynta Co | Prynta Co