The 10 ZPL Font Commands Every Developer Should Know
zplreferencecheat-sheetZPL has hundreds of commands, but you can print good text labels with about ten. If you’re new to it, or you’ve inherited a pile of label code and want to understand what it’s doing, these are the ones to learn first. Each comes with a short example you can paste into the live preview.
1. ^XA and ^XZ: start and end
Every label begins with ^XA and ends with ^XZ. Everything between belongs to one label. Forgetting the closing command is a classic reason for a label not printing, because the printer is still waiting for more.
2. ^PW and ^LL: the label’s size
^PW sets the printable width in dots and ^LL sets the label length. Don’t rely on whatever the printer was configured with. Setting them yourself makes your label independent of the printer’s state, and it’s the first thing to check when text is clipped. A four-inch label at 203 DPI is ^PW812.
3. ^FO: where the field goes
^FO40,100 puts the next field’s top-left corner 40 dots from the left and 100 from the top. It’s the command you’ll write most. There’s a sibling, ^FT, which positions by the text baseline and is better for lining up different sizes on one line.
4. ^A: pick the font and size
^A0N,40,40 means font 0, normal orientation, 40 dots high, 40 wide. Note there’s no comma between A and the font letter. For bitmap fonts, sizes snap to multiples, and for downloaded fonts you use ^A@ with the file name. The ^A command guide covers all of it.
5. ^CF: set the default
^CF0,30 sets the font and size for any field that doesn’t have its own ^A. It’s a safety net. Without it, a field you forget to style falls back to a tiny factory default, which is rarely what anyone wants.
6. ^FD and ^FS: the actual text
^FD introduces the data and ^FS ends the field. Everything between is the text to print. The two characters you can’t put in directly are the caret and the tilde, because the printer reads them as commands.
7. ^FH: hex escapes
Turn on ^FH before the data and you can write any byte as an underscore plus two hex digits. It’s the dependable way to include special characters when you can’t trust how your text will be encoded on the way to the printer: ^FH^FDCaf_C3_A9^FS prints “Café” when UTF-8 is selected. The label generator can produce this automatically.
8. ^CI: the character set
^CI28 makes the printer read text as UTF-8. Get this wrong and accents turn into nonsense. It stays in force until changed, so set it at the top of each label rather than relying on a previous job. The table of values lives in Unicode and code pages.
9. ^FB: wrap and align
^FB700,4,0,L,0 wraps text inside a box 700 dots wide, up to four lines, left-aligned. It’s the only way to wrap and the easy way to centre. Mind the line limit, because extra lines are dropped. We have a full article on wrapping text with ^FB.
10. ^CW: give a font a short name
^CWZ,E:ARIAL.TTF assigns the letter Z to a stored font, so later you can write ^AZN,50,50 instead of the long ^A@ form. It keeps label code readable when you use a custom font often. Installing the font in the first place is explained in how to install a TrueType font.
Honourable mentions
^FR reverses a field, printing white on black. ^FW sets a default orientation for the whole label. ^FP handles right-to-left text. ^GB draws boxes and lines. ^GF prints bitmap graphics. And ^BY and ^BC are your starting point for barcodes. If you’re curious about graphics, read printing any font as a graphic.
A tiny label using all the essentials
^XA
^CI28
^PW812
^LL406
^CF0,30
^FO40,40^A0N,48,48^FDProduct name^FS
^FO40,110^A0N,30,30^FB700,3,4,L,0^FDA longer description that wraps within the box.^FS
^FO40,250^FH^A0N,28,28^FDCaf_C3_A9 crème^FS
^XZ
Keep a cheat sheet handy
You don’t need to memorise any of this. Print our one-page cheat sheet and stick it near the printer, or save it as a PDF. And when something goes wrong, the troubleshooting section is organised by symptom.