ZPL guide 4 of 9

Linear barcodes: Code 128, Code 39, EAN, UPC and more

The recipe for any ZPL barcode, how to size one with ^BY, which symbology fits which data, how check digits work, and the quiet-zone and density limits that decide whether it scans.

The recipe for any barcode

Question What is the general recipe for a barcode?

A barcode field is built from a barcode command and its data in ^FD, closed with ^FS, and placed with ^FO like any other field. Optionally, ^BY goes before it to set defaults.pp. 148, 201, 204, 1587

Each barcode command can be followed by a parameter string: orientation, height and whether to print the human-readable interpretation line, plus, for some symbologies, a check digit or start and stop characters. The guide says every parameter has a default.p. 1588

Parameters are position-specific. To change only the third, send two commas and then the value, and the first two keep their defaults.p. 1588

^FO places the barcode by its upper-left corner. ^FT places it by its base instead: for a barcode the origin is the base of the code at the left edge, and the guide advises against ^FT without coordinates for the first field in a format. If the data holds characters you cannot type, ^FH, described in the text and fonts guide, lets you write them as hexadecimal.pp. 193, 201, 205, 206

WarningOrientation is N, R, I or B and defaults to the current ^FW value, with one exception worth knowing: for ^BR the guide gives a default of R. Set orientation explicitly for ^BR.pp. 94, 135

example.zplZPL
^XA
^FO40,40^BY3
^BCN,90,Y,N,N,A
^FDLOT7781234^FS
^XZ

A Code 128 barcode: normal orientation, 90 dots high, interpretation line below, no UCC check digit, and automatic mode, which picks subsets for you.

Sizing with ^BY

Question How do I set bar width, ratio and height?

^BY sets three defaults for the barcodes that follow: module width (the narrow bar) in dots, from 1 to 10; the wide-to-narrow ratio, from 2.0 to 3.0; and the height in dots. At power-up the module width is 2 and the height is 10, and a ^BY stays in effect until the next one.pp. 148, 149

Each barcode command can override the height itself. If it does not, ^BY supplies it.pp. 94, 148

The ratio has no effect on fixed-ratio symbologies, which the guide marks in its table of barcode commands: Code 128, EAN-13, UPC-A, EAN-8, UPC-E, Code 93 and GS1 DataBar are fixed, while Interleaved 2 of 5, Code 39 and Codabar accept 2.0 to 3.0.pp. 1587, 1588

The ratio you ask for is not always the ratio you get, because the printer can only make whole dots. At a module width of 3 dots, asking for 2.5 gives 2.3:1 in the guide's table, though the guide's own worked example (9 dots, asking for 2.4, giving 2.44) does not match the same table, so treat the table as approximate.p. 148

Choosing a symbology

Question Which symbology should I pick?

Numeric-only data suits Interleaved 2 of 5 (^B2), which needs an even number of digits and adds a leading zero if you send an odd count.pp. 68, 69

Alphanumeric data suits Code 128 (^BC), Code 39 (^B3) and Code 93 (^BA). Code 39 generates its own start and stop characters and can encode the full 128-character ASCII set through paired characters, although extended ASCII depends on the scanner having it enabled. Code 128 has three character subsets and, with no start code, defaults to subset B; its automatic mode shifts to subset C for four or more digits in a row.pp. 70, 71, 87, 95, 98, 1589

Retail labeling uses EAN-13 (^BE, 12 data characters), UPC-A (^BU, 11), EAN-8 (^B8, 7) and UPC-E (^B9, 10). The first three have an exact length: shorter data is padded on the left with zeros, and the guide says longer data is truncated without saying which end is cut. UPC-E expects you to send the full ten characters (a five-digit manufacturer code and a five-digit product code) and works out the shortened form itself.pp. 83, 85, 109, 142, 1589

Codabar (^BK) takes a start and stop character, and GS1 DataBar (^BR) is one command with a symbology-type parameter. Values 1 to 6 select the Omnidirectional, Truncated, Stacked, Stacked Omnidirectional, Limited or Expanded variant; values 7 to 12 select UPC-A, UPC-E, EAN-13, EAN-8 and two UCC/EAN-128 forms.pp. 118, 135

Check digits and the interpretation line

Question What are check digits, and how do I print the text under the code?

The interpretation line is the readable text. Most of the linear barcode commands here have a parameter to turn it on (default yes) and another to print it above the code instead of below (default no); ^BR has neither. For ^BC, a font command placed before the barcode command chooses the font of the line, while for ^BU the guide ties the font style to the module width.pp. 70, 94, 135, 142, 143

Check digits vary by symbology. Interleaved 2 of 5 has an optional Mod 10 digit and Code 39 an optional Mod 43 digit. Code 128 always includes a Mod 103 check; its UCC check digit option adds Mod 10 as well. EAN-13 and UPC-A use Mod 10, and ^BU has a parameter to print the check digit, default yes.pp. 68, 70, 94, 110, 142, 143

The guide works one example of each calculation, but the Mod 43 example has flaws: its data string is 2345ABCDE/, yet the sum shown starts with an extra 1, and its table of character values skips M to W. Check any hand calculation against the rules rather than that example.pp. 1591, 1592

example.zplZPL
^XA
^FO40,40^BY2,2.5^B3N,Y,90,Y,N^FDAB-1234^FS
^XZ

Code 39 with the Mod 43 option on, a 2.5 ratio and the readable line below the bars.

example.zplZPL
^XA
^FO40,40^BY2
^BEN,90,Y,N
^FD123456789012^FS
^XZ

EAN-13 takes exactly 12 data characters in ^FD.

Why a barcode does not scan

Question What does the guide say about scannability?

Every barcode needs a quiet zone, a clear area around it where nothing may print. It is usually ten times the width of the narrow bar, so a wider module width needs more clear space.p. 1586

WarningOn an 8 dots per millimeter printhead, UPC and EAN symbologies are produced at a magnification factor of 77 percent, while 6, 12 and 24 dots per millimeter heads produce them at 100 percent. Test 8 dots per millimeter retail codes with your scanner.pp. 85, 142

Check the data length too. For Code 128, Code 39 and several others the field data is limited to the width of the label, or its length if rotated.pp. 70, 94

The same label with BarcoderX

Question Where does BarcoderX fit in?

BarcoderX is pre-launch and its API is not final. It is designed to let you describe the label once in .NET and emit ZPL or EPL. Linear and postal symbologies, including every GS1 DataBar variant, are in the Basic edition; see Pricing. The published samples on the Developers page do not show barcode calls yet, so there is no code here.

Questions

Why does ^BY have no effect on my ratio?

The ratio only applies to symbologies with a variable ratio, such as Code 39 and Interleaved 2 of 5. Code 128 and the retail codes are fixed.pp. 148, 1587

How many characters does EAN-13 take in ^FD?

Exactly 12. The guide says ZPL pads shorter data on the left with zeros and truncates longer data, without saying which end is cut.p. 109

How do I skip a barcode parameter?

Parameters are position-specific, so send a comma for each parameter you skip.p. 1588

Commands in this guide

BarcoderX is a .NET SDK for thermal labels and barcodes. See the barcode types it covers.

Source Zebra, ZPL II, ZBI 2, Set-Get-Do, Mirror, WML Programming Guide, P1134473-11EN Rev A, 2026/07/05, pages 68 to 71, 83, 85, 87, 94, 95, 98, 109, 110, 118, 135, 142, 143, 148, 149, 190, 193, 201, 204 to 206, 1586 to 1589, 1591, 1592.

Written by BarcoderX in its own words. Checked against the guide on 2026-11-14.

ZPL and ZPL II are trademarks of Zebra Technologies Corporation. This reference is written by BarcoderX in its own words from Zebra's published programming guide. BarcoderX is an independent product and is not affiliated with, endorsed by or sponsored by Zebra Technologies.