BARCODE DATALINK Since 1991

Home/Printers/ZPL

ZPL · Zebra Programming Language

ZPL. The language the printer speaks.

If you need to drive a Zebra label printer from your own software — a PC application, a warehouse system, a handheld out on the floor — without going through a Windows printer driver, ZPL is the answer. You send the printer text. It prints a label.

No driver, no print spooler, nothing to install on the machine sending it. That is the whole appeal, and it is why a language designed decades ago is still the normal way to talk to a Zebra printer today.

Start here

A label, and the code that prints it.

This one was designed in Zebra BarOne version 5, which is long gone, and BarOne would “print” the design to a text file instead of to a printer. The design is a Code 39 barcode reading HELLO. This is what came out.

Zebra BAR-ONE version 5 running on Windows, showing a label design with a
                  Code 39 barcode reading HELLO. The title bar names the printer as a
                  Z4M55/TLP2844 at 200 dpi.
The label, in BarOne v5. The title bar says Z4M55/TLP2844 and 200 dpi, which dates it about as precisely as anything on this site.
^XA
^PRA
^LH0,0^FS
^LL384
^MD22
^MMR
^MNY
^LH0,0^FS
^BY3,3.0^FO52,28^B3N,N,100,Y,N^FR^FDHELLO^FS
^PQ1,0,0,N
^XZ
^FX End of job
^XA
^IDR:ID*.*
^XZ
The three that matter

Start, finish, and the one doing the work

^XA opens a label and ^XZ closes it. Everything between them is one label. The line in the middle is the only one that prints anything — the rest is setup.

Reading that middle line

Where, what, and how big

^FO52,28 is the field origin — 52 dots across, 28 dots down. ^B3 is Code 39 and the 100 is its height in dots. ^FD is the field data, so ^FDHELLO is what gets encoded, and ^FS ends the field.

Save it in Notepad and send it. On a serial printer, from a command prompt: copy filename.txt com1. On a parallel one, copy filename.txt lpt1. Those are the original instructions and they still work on a printer old enough to have those ports. A network printer takes the identical file on port 9100 — same idea, over a cable that still exists.

The part nobody writes down

ZPL counts in dots, not millimetres.

This is the whole of it, and it is the thing that catches people out when a label prints in the wrong place.

203 dpi

8 dots per millimetre

The resolution most warehouse labels are printed at, and always have been.

300 dpi

12 dots per millimetre

For small type and dense 2D codes. Which resolution a job actually needs is a different question, and it is answered on the printers page rather than twice.

So moving something is arithmetic, not guesswork. Take that line again:

^BY3,3.0^FO52,28^B3N,N,100,Y,N^FR^FDHELLO^FS

To move the barcode 1 mm to the right on a 203 dpi printer, add 8 dots: ^FO52 becomes ^FO60. To move it 5 mm down, 8 × 5 = 40 dots, so 28 becomes 68. Both together:

^BY3,3.0^FO60,68^B3N,N,100,Y,N^FR^FDHELLO^FS

And this is the trap. Because those numbers are dots and not millimetres, the same file prints in a different physical place on a different printer. ^FO52,28 is 6.5 mm across on a 203 dpi head and 4.3 mm across on a 300 dpi one — the same instruction, two thirds of the distance. A label format that has been correct for years will land wrong the day it is sent to a finer printer, and nothing in the file changed.

Three languages, one manufacturer

ZPL, EPL or CPCL?

Zebra has shipped three of them. Which one a printer understands depends on what it is and roughly when it was built, and a file written in the wrong one does nothing at all.

ZPL — use this one

Everything Zebra sells now speaks it: the ZD220, ZD421 and ZD621 on a desk, the ZT411, ZT421 and ZT510 in a warehouse, the ZQ620 and ZQ630 on a belt.

Historically also the LP and TLP2844-Z, the TLP3844-Z, G-Series GK and GX, S4M, 105SL, ZM Series, Xi Series, and the QL and P4T mobile printers.

EPL — the older desktops

The LP2844, TLP2844, G-Series, QL Plus, P4T and RW Road Warrior.

This is usually the answer to a good question. If a label format has been printing since the 2000s and will not run on a new printer, it is generally because the file is EPL and the new printer is listening for ZPL.

CPCL — the mobile ones

Written for mobile printers and best suited to the QL series, the P4T and the RW Road Warrior. For an RW, use CPCL.

If you get to choose, choose ZPL. It is on board every current printer, it is the one Zebra still documents, and it is easier to read once you know what ^FO and ^FD are doing. The only good reason to write anything else is a printer that will not take it.

If you would rather not hand-write it

Let the software generate it.

Typing dot coordinates is fine for one barcode and miserable for a real label. Both the old way and the current way will write the ZPL for you.

BarTender, print to file

Design the label on screen, then File → Print, click Options, tick Print to File. Click Print and it asks for a filename instead of printing. What lands in that file is the ZPL for the label you just drew.

What BarTender costs, and whether you need it at all.

The manual, all 1,769 pages

Zebra's own ZPL II, ZBI 2, Set-Get-Do, Mirror and WML programming guide. Every command and every parameter, and the reference behind everything on this page.

Programming ZPL II and ZBI 2 programming guideZebra · PDF, 16.8 MB Download →

The BarTender print dialogue on the Options tab with the Print to File
                  checkbox ticked. The printer is a Zebra Z4M Plus at 300 dpi and the label
                  file is named ean-13.
Print to File, ticked. The label in that dialogue is ean-13.btw going to a 300 dpi printer — which is the resolution an EAN-13 at 100% actually needs.

Stuck on a label that will not print right?

Send us the ZPL and a photograph of what came out. Wrong position, wrong size, or the wrong language for the printer — it is nearly always one of those three, and it is quicker for us to read it than to explain how.