ZPL tutorial: commands and examples
This ZPL tutorial covers the handful of commands behind every Zebra label: ^XA and ^XZ to start and end, ^FO to place a field, ^A0 to pick a font, ^FD and ^FS for the data, and ^BC and ^BQ for barcodes. Each one comes with an example you can paste into a viewer.
How it works
A ZPL label, one command at a time
Skip the ZPL and design the label
Draw the label in the editor and print it. The ZPL is written for you, and you can copy it out whenever you need it. No signup.
Open the free label maker- Good forReading ZPL you inherited, debugging a label, or sending labels from a backend.
- You needNothing to print. The free label maker writes the ZPL for you.
- Worth knowingZPL counts in dots, so the same code prints differently at each DPI.
1ZPL
What ZPL is
Every label a Zebra prints is a tiny program in ZPL, the Zebra Programming Language.
The printer doesn't take PDFs or Word files. It takes ZPL commands, one after another, until it reaches a marker that says the label is done. Then the head fires.
You don't need to learn ZPL to print. The free label maker writes it for you. The basics still help, for two reasons:
By the end you'll be able to look at a ZPL string and roughly see the label it makes. The last part shows how Copy ZPL works, so you can plug it into your own pipeline.
- When something goes wrong (a blurry barcode, cut-off text, a missing field), it's usually traceable to one specific command.
- If you build any backend automation, like a print queue, an ERP integration, or a fulfillment script, you'll eventually copy ZPL out of an editor and send it from your own code. It helps to know what's in that string.
2Examples
Labels to try it with
These are real renders from the editor, with made-up details. Click one and it opens with that exact label.



3ZPL
The shape of a ZPL label
The simplest possible ZPL label looks like this:
// Start a label ^XA // Move to position (50, 50) and print "Hello World" ^FO50,50^A0N,36,36^FDHello World^FS // End the label, fire the printer ^XZ
Every label, however complex, starts with ^XA and ends with ^XZ. Everything between is a sequence of commands.
Each command is a caret (^) and two letters that name it, plus optional parameters separated by commas.
The example uses the bare minimum:
^FO50,50is Field Origin. It sets the position for the next thing you draw, in dots from the top-left corner. So50,50means 50 dots right and 50 dots down.^A0N,36,36picks a built-in font: font 0, no rotation, 36 dots tall and 36 dots wide. Think of it as the font and size picker.^FDis Field Data, followed by the text you want to print.^FS, Field Separator, ends the field.
4Settings
Dots, DPI, and why coordinates feel weird
All ZPL coordinates and sizes are in dots, the physical resolution of the print head. Three DPI tiers cover almost everything:
That sounds like a detail, but it changes the print. The same ZPL string lands differently on printers with different DPI.
A ^FO100,100 on a 203 DPI printer puts your field about half an inch in. On a 600 DPI printer, the same command puts it about 0.17 inch in. ZPL has no idea what an inch is. Everything is dots.
That's why mylabelmaker tracks the active printer's DPI and renders at the printer's native resolution. Why your Zebra prints fuzzy at 300 DPI has the full story.
- 203 DPI: 1 inch is 203 dots. A 4-inch label is 812 dots wide.
- 300 DPI: 1 inch is 300 dots. A 4-inch label is 1,200 dots wide.
- 600 DPI: 1 inch is 600 dots. A 4-inch label is 2,400 dots wide.
5ZPL
ZPL commands you'll see most often
| Command | What it does |
|---|---|
| ^XA | Start of label. Always the first thing. |
| ^XZ | End of label. The printer fires when it sees this. |
| ^PW n | Print width in dots. Optional, defaults to the printer's loaded label width. |
| ^LL n | Label length in dots. Same idea for height. |
| ^PQ n | Print Quantity. ^PQ3 means "print 3 copies of this label". |
| ^FO x,y | Field Origin. Where to place the next thing. |
| ^FD text | Field Data. The actual content of a text or barcode field. |
| ^FS | Field Separator. "I'm done defining this field." |
| ^A0N,h,w | Use scalable font 0, rotation N (normal), height h dots, width w dots. |
| ^BC | Code 128 barcode. |
| ^BQ | QR code. |
| ^BY w,r,h | Set barcode field defaults (module width, ratio, height). |
| ^GFA | Graphic Field, ASCII. The most powerful command. Embeds a 1-bit bitmap directly in the ZPL. |
| ^MD n | Media Darkness. 0 to 30. Controls how dark the print is. (Higher = darker.) |
| ^PR n | Print Rate. Inches per second the head moves. Lower = sharper, higher = faster. |
| ~JR | Reset printer (rarely needed). |
You can write a complete label by hand with just these. A small product label with a name, a price, and a barcode is about ten lines.
Paste a short job and preview ZPL in the browser to check ^FO, ^A, ^BC, or ^BQ before you print.
6Examples
A ZPL example, line by line
Here's a fuller label, the kind mylabelmaker produces when you design a shipping label:
^XA
^MD12
^PR4
^PW812
^PQ1
^FO0,0
^GFA,121800,121800,150,[hex bitmap data omitted]^FS
^XZ
That ^GFA is mylabelmaker's default approach. It renders the whole canvas (text, barcodes, QR, shapes, images) into one bitmap at the printer's native DPI, then sends it as a single graphics field.
It's the most reliable way to make the printed label match the screen, because it skips the printer's own font rendering, barcode generation, and any firmware quirks.
^A0) and barcode encoders (^BC, ^BQ). Those strings are smaller, but they tie you to whatever fonts your printer has loaded and to its own barcode implementation. Pre-rendering to ^GFA means the same ZPL gives identical output on any Zebra with the same DPI.^XAstarts the label.^MD12sets darkness to 12, a sensible mid-range value for a fresh ribbon.^PR4prints at 4 inches per second.^PW812sets the print width to 812 dots, which is 4 inches at 203 DPI.^PQ1prints 1 copy.^FO0,0puts the next field at the top-left corner.^GFA,121800,121800,150,…embeds a 121,800-byte bitmap, 150 bytes per row, as the whole label.^FScloses the field.^XZfires the printer.
7ZPL
Get ZPL out of mylabelmaker
You don't have to write any of this. The editor generates the ZPL for whatever you design. To grab it:
- Open https://app.mylabelmaker.com. No signup.
- Pick a size and drop in text, barcodes, QR codes, or images, whatever the label needs.
- Open printer settings (the gear icon) and use Auto-detect, so the label renders at your printer's actual DPI.
- Click Options in the top-right of the editor, then Copy ZPL. The full
^XA … ^XZstring for the current label goes to your clipboard. - Paste it wherever you need it: a text file, a print server, a request to your fulfillment API, a chat message.
8Your list
Variables and batch print
When you batch print from a CSV or Google Sheet, mylabelmaker generates a separate ZPL string for each row, with that row's values filled in, and sends them one after another.
Copy ZPL copies just the current row. That's handy for testing one row in your backend before you turn it loose on the whole sheet.
9ZPL
Send ZPL from your own code
Once you have the string, your backend can send it to a Zebra over a TCP socket (port 9100 on network printers), through the Browser Print helper's localhost API, or through any Zebra print server.
The simplest example, a network-connected ZD621 at 192.168.1.50:
# Python import socket zpl = "^XA^FO50,50^A0N,36,36^FDHello^FS^XZ" s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(("192.168.1.50", 9100)) s.send(zpl.encode("utf-8")) s.close()
That's the whole pattern. In any language: open a TCP socket to the printer's IP on port 9100, write the ZPL bytes, close. The printer fires as soon as it sees ^XZ.
10Your list
The short list for skimming ZPL
If you're reading ZPL someone else generated, from a previous developer or a system you inherited, these are the ones you'll meet:
ZPL at a glance
^XA … ^XZwraps every label.^FO x,ypositions the next field.^A0N,h,wpicks the font and size.^FD … ^FSholds and ends a field's data.^BCis Code 128, and^BQis QR.^GFAembeds a bitmap.^PQis quantity,^MDis darkness, and^PRis speed.
Everything else is a variation on these, or a specialty command for things like RFID encoding, status queries, or printer configuration. The official ZPL II reference, a free PDF from Zebra, covers the long form if you ever need it.
11Good to know
The takeaway
ZPL is a small, plain ASCII command language that's been around since the 1990s and shows no sign of going away.
You don't need to write it. The editor handles the quirks (DPI mapping, font rasterization, barcode encoding, bitmap packing) and sends a clean ^XA … ^XZ string to your printer.
You don't need to write ZPL, but knowing what's in the string makes you better at debugging it.
It also helps when you connect a backend, or when someone asks what the label software is actually doing.
Questions about this ZPL tutorial
What are the basic ZPL commands?
^XA starts a label and ^XZ ends it. ^FO sets where the next field goes, ^A0 picks a font and size, ^FD holds the data, and ^FS ends the field. ^BC is a Code 128 barcode and ^BQ is a QR code.
Why does the same ZPL print differently on another Zebra?
ZPL counts in dots, not inches. A 203 DPI printer has 203 dots per inch and a 600 DPI printer has 600, so the same coordinates land in a different place. Match the DPI to the printer.
Do I need to learn ZPL to print to a Zebra?
No. The free label maker writes the ZPL for whatever you design. Knowing the basics helps when you debug a label or send ZPL from a backend.
How do I copy ZPL out of mylabelmaker?
Design the label, then click Options and Copy ZPL. The full ^XA to ^XZ string for the current label goes to your clipboard. With a spreadsheet loaded, it copies the current row.
How do I preview ZPL before printing?
Paste the code into the free ZPL viewer and it shows you a picture of the label in the browser. No signup.