MakeZPL

Reference

Barcodes in ZPL

Eight symbologies, the exact ZPL command for each, the data rules that decide whether the printer accepts your value, and the two settings — module width and quiet zone — that decide whether the finished label actually scans.

Add a barcode in the designer Full command reference

^BY: the setting that makes or breaks the scan

^BY sets the narrow-bar width in dots, the wide-to-narrow ratio, and a default height. It is state: it applies to every barcode after it until the next ^BY, which is why one stray value can quietly change three barcodes.

What ^BY controls on a ZPL barcode A Code 128 barcode with the narrow bar width labelled as the first ^BY parameter and the bar height labelled as the third, plus the human-readable interpretation line underneath. 4125500001 ^BY 4 — narrow bar = 4 dots 90 dots tall
The narrow bar width is the unit every other bar is measured in. Too thin and the printer cannot lay the bars down cleanly; too wide and the code runs off the label. The height is set in both ^BY and the barcode command — the last one wins.
Sensible starting values for the ^BY narrow-bar width by print resolution.
Resolution Minimum Comfortable Narrow bar, comfortable
203 dpi230.38 mm
300 dpi340.34 mm
600 dpi680.34 mm

Note what the last column shows: the same physical bar width needs a different ^BY at every resolution. Copying a 203 dpi label onto a 600 dpi printer without changing ^BY produces a barcode a third of the intended size. Sizes and dpi covers the rest of that conversion.

The symbologies, with working ZPL

Every snippet below is exactly what MakeZPL emits for that barcode type. Drop one between ^XA and ^XZ and it will print.

Code 128 — ^BC

The default choice for anything alphanumeric: SKUs, order numbers, licence plates, GS1 data.

Data rules: Any ASCII character from space to ~ (32–127).

^FO30,60
^BY3,2,90
^BCN,90,Y,N,N
^FD4125500001^FS

Dense, self-checking and variable length. If you do not have a reason to pick something else, pick this.

Code 39 — ^B3

Older warehouse and automotive systems, and anywhere a scanner is configured for Code 39 only.

Data rules: Digits, uppercase A–Z, and - . space $ / + %. Lowercase will not encode.

^FO30,60
^BY3,2,90
^B3N,N,90,Y,N
^FDBIN-C14^FS

About 30% wider than Code 128 for the same data. The second parameter turns the mod-43 check digit on.

UPC-A — ^BU

Retail products sold in North America.

Data rules: 11 or 12 digits. Give 11 and the printer calculates the check digit.

^FO30,60
^BY3,2,90
^BUN,90,Y,N,Y
^FD07253100640^FS

Fixed length and fixed proportions — do not squeeze it below about 80% of nominal size or scanners at the till will struggle.

EAN-13 — ^BE

Retail products sold outside North America.

Data rules: 12 or 13 digits.

^FO30,60
^BY3,2,90
^BEN,90,Y,N
^FD501234567890^FS

The 13th digit is the check digit; supply 12 and the printer works it out.

EAN-8 — ^B8

Small retail packaging where a full EAN-13 will not fit.

Data rules: 7 or 8 digits.

^FO30,60
^BY3,2,90
^B8N,90,Y,N
^FD9638507^FS

Only use it when EAN-13 genuinely does not fit — the shorter number space is allocated separately.

Interleaved 2 of 5 — ^B2

Cartons and outer packaging, especially ITF-14 shipping container codes.

Data rules: Digits only, and an even number of them.

^FO30,60
^BY3,2,90
^B2N,90,Y,N,N
^FD00104822000037^FS

An odd digit count is the classic ITF bug: the printer pads it and the scan comes back wrong. MakeZPL blocks the export instead.

QR code — ^BQ

Linking a label to a record, a URL or a maintenance history from a phone camera.

Data rules: Any text, including URLs and multi-line payloads.

^FO30,60
^BQN,2,6
^FDQA,https://example.com/asset/41255^FS

The Q in ^FDQA, is the error-correction level (H, Q, M or L) and A is automatic input mode. The third ^BQ parameter is magnification, 1–10.

Data Matrix — ^BX

Marking small parts, PCBs and instruments where there is very little room.

Data rules: Any text. Denser than QR at small sizes.

^FO30,60
^BXN,6,200
^FD41255-A^FS

The second parameter is the module size in dots and the third is the quality level; 200 is the modern ECC 200 encoding.

Picking one in ten seconds

Which ZPL barcode command to reach for.
If your data is… Use Command
Letters and digits, any lengthCode 128^BC
Uppercase only, legacy scannerCode 39^B3
A retail product, North AmericaUPC-A^BU
A retail product, elsewhereEAN-13^BE
An even-length carton numberInterleaved 2 of 5^B2
A URL or a long payloadQR code^BQ
A payload on a tiny partData Matrix^BX

MakeZPL validates the value against the symbology before it lets you export. Feed 13 digits to a UPC-A barcode or an odd number of digits to Interleaved 2 of 5 and you get a blocking error with the reason, not a label that prints and then fails at the scanner.

Three things that stop a printed barcode scanning

No quiet zone

A barcode needs blank label at both ends — at least ten narrow-bar widths, so 30 dots at ^BY3. Butting a code against a box drawn with ^GB, or against the edge of the label, is the most common cause of a code that looks perfect and reads never.

Darkness set too high

Excess heat spreads each bar sideways. The bars merge, the narrow:wide ratio drifts out of tolerance, and the scanner rejects the code. Turn ^MD down until the bars look crisp rather than bold.

Rotation without room

A barcode rotated with R or B still needs its full length. Rotate a 500-dot code on a 406-dot-tall label and the printer clips it silently — MakeZPL flags it as an out-of-bounds error before you print.

Barcode FAQ

Symbology choice, check digits, sizing and why codes fail to scan.

Which barcode should I use on a warehouse label?

Code 128 unless something forces your hand. It encodes the full ASCII range, is denser than Code 39, and every modern scanner reads it. Use Interleaved 2 of 5 for ITF-14 carton codes, and UPC-A or EAN-13 only for retail point-of-sale.

Why does my barcode print but not scan?

Nine times out of ten the narrow bar is too thin for the print resolution, or there is not enough white space around the code. At 203 dpi keep ^BY at 2 or more — 3 is safer — and leave a quiet zone of at least ten narrow-bar widths at each end. Excess darkness also fattens the bars until the ratios go out of tolerance.

How tall should a barcode be?

Tall enough for the scanner to find a clean scan line: about 15% of the code's length, and rarely less than 60 dots at 203 dpi. Height costs you nothing but label space, so err upward.

Do I need to include the check digit?

For UPC-A and EAN you can supply the value without its final check digit and the printer calculates it. Code 128 and Data Matrix carry their own internal check characters. Code 39 has an optional mod-43 check digit that is off by default.

Can one label have several barcodes?

Yes. Each is its own ^FO plus barcode command plus ^FD block. Remember that ^BY is state: it applies to every barcode after it until you set it again, which is a common cause of one code printing at the wrong module width.

What is the difference between QR and Data Matrix?

Both are 2D codes holding roughly the same kinds of data. QR is more widely recognised and reads well from phone cameras; Data Matrix packs the same payload into a smaller mark, which is why it dominates small-part and electronics marking.