ZPL Command Reference
A complete quick-reference guide for ZPL II (Zebra Programming Language) commands. All commands listed below are supported by Printivo's label rendering API.
ZPL Label Structure
Every ZPL label begins with ^XA and ends with ^XZ. Commands inside this block define the label content and layout.
^XA ← Start label
^FO50,50 ← Field origin: x=50 dots, y=50 dots
^A0N,40,40 ← Font: scalable, no rotation, 40×40 dots
^FDHello World^FS ← Field data + field separator
^FO50,120 ← Second field origin
^BY3 ← Barcode default: bar width = 3
^BCN,100,Y,N,N ← Code 128 barcode, height=100
^FD123456789^FS ← Barcode data
^XZ ← End label
Printivo renders at 203 DPI by default (standard Zebra). Use the dpi parameter in the API to request 300 or 600 DPI output.
Label Format Commands
| Command | Name | Parameters | Description |
|---|---|---|---|
^XA |
Start Label | — | Marks the start of a ZPL label. Required. Every label must begin with this command. |
^XZ |
End Label | — | Marks the end of a ZPL label. Required. Every label must end with this command. |
^LH |
Label Home | ^LHx,y |
Sets the label home position (origin offset). All subsequent ^FO positions are relative to this point. Default: ^LH0,0. |
^LL |
Label Length | ^LLy |
Sets the label length in dots. Useful for cutting labels to exact size. |
^PW |
Print Width | ^PWa |
Sets the label print width in dots. |
^PQ |
Print Quantity | ^PQq,p,r,o |
Specifies the number of labels to print. Ignored by Printivo (renders one label per request). |
^PO |
Print Orientation | ^PON|I |
Normal (N) or inverted (I) label orientation. |
Field Commands
| Command | Name | Parameters | Description |
|---|---|---|---|
^FO |
Field Origin | ^FOx,y,z |
Sets the position of the next field. x = horizontal dots from left, y = vertical dots from top. z = justification (0=left, 1=right, 2=auto). |
^FT |
Field Typeset | ^FTx,y,z |
Alternative to ^FO. Positions the field baseline (useful for text alignment). |
^FD |
Field Data | ^FDdata^FS |
Defines the content (data) of a field. Always followed by ^FS. For barcodes, ^FD provides the data to encode. |
^FS |
Field Separator | — | Ends a field definition. Required after every ^FD command. |
^FR |
Field Reverse | — | Reverses the color of a field (white on black instead of black on white). |
^FW |
Field Orientation | ^FWr |
Sets the default field orientation. N=normal, R=90° clockwise, I=inverted, B=bottom-up. |
^FX |
Comment | ^FXtext |
Comment command — content is ignored during rendering. Useful for annotating ZPL code. |
^FB |
Field Block | ^FBw,l,s,j,h |
Formats text into a block with defined width (w), max lines (l), line spacing (s), justification (j: L/R/C/J), and hanging indent (h). |
Font & Text Commands
| Command | Name | Parameters | Description |
|---|---|---|---|
^A / ^A0 |
Scalable Font | ^A0r,h,w |
Uses Font 0 (scalable). r=rotation (N/R/I/B), h=character height in dots, w=character width in dots. Most commonly used font for labels. |
^CF |
Change Default Font | ^CFf,h,w |
Sets the default font for subsequent text fields. f=font name, h=height, w=width. |
^CFA |
Change Font A | ^CFAh,w |
Sets the size of Font A. Alternative to ^CF for the built-in proportional font. |
^CI |
Change International | ^CIn |
Selects the international character set (encoding). Common values: 0=USA, 28=UTF-8. |
Barcode Commands
Barcode commands are followed by ^FD (the data to encode) and ^FS. Use ^BY before the barcode command to set bar width and ratio.
| Command | Barcode Type | Key Parameters | Example |
|---|---|---|---|
^BY |
Barcode Default | ^BYw,r,h |
Sets defaults: w=bar width (1–10), r=ratio, h=height in dots. Applied to the next barcode. Example: ^BY3,3,100 |
^BC |
Code 128 | ^BCr,h,p,u,d |
High-density alphanumeric. r=rotation, h=height, p=print interpretation line (Y/N), u=above (Y/N), d=check digit (Y/N). Example: ^BCN,100,Y,N,N |
^B3 |
Code 39 | ^B3r,c,h,p,u |
Alphanumeric barcode. c=check digit (Y/N), h=height. Encodes A–Z, 0–9, and special chars. |
^BE |
EAN-13 | ^BEr,h,p,u |
13-digit international retail barcode. Data must be 12 digits (check digit auto-calculated). |
^B8 |
EAN-8 | ^B8r,h,p,u |
Compact 8-digit EAN barcode for small product packaging. |
^BU |
UPC-A | ^BUr,h,p,u,d |
12-digit North American retail barcode. Data must be 11 digits (check digit auto-calculated). |
^B9 |
UPC-E | ^B9r,h,p,u,d |
Compressed 6-digit UPC for small items. |
^BQ |
QR Code | ^BQr,m,q |
2D QR code. m=model (2=standard), q=error correction (M=15%, H=30%). Example: ^BQN,2,Q |
^BX |
DataMatrix | ^BXr,h,q |
2D DataMatrix barcode. Used for small parts marking (GS1, aerospace, pharma). |
^B7 |
PDF417 | ^B7r,h,s,c,r2 |
2D stacked barcode used on ID cards, transport documents, and boarding passes. |
^B0 |
Aztec | ^B0r,m,e |
2D Aztec barcode, commonly used for transit tickets and boarding passes. |
^B2 |
Interleaved 2 of 5 | ^B2r,h,p,u,d |
Numeric-only barcode used in warehouse and distribution environments. Must be even number of digits. |
^BA |
Code 93 | ^BAr,h,p,u,d |
Higher density than Code 39. Encodes same character set with fewer bars. |
Barcode Example
^XA
^FO50,50
^BY3,3,100 ← Bar width=3, ratio=3, height=100 dots
^BCN,100,Y,N,N ← Code 128, normal, height=100, print text below
^FD12345678^FS ← Encode "12345678"
^XZGraphic Commands
| Command | Name | Parameters | Description |
|---|---|---|---|
^GB |
Graphic Box | ^GBw,h,t,c,r |
Draws a rectangle or filled box. w=width, h=height, t=border thickness, c=color (B=black/W=white), r=corner rounding (0–8). Example: ^GB200,100,3,B,0 |
^GC |
Graphic Circle | ^GCd,t,c |
Draws a circle. d=diameter, t=border thickness, c=color. |
^GD |
Graphic Diagonal | ^GDw,h,t,c,o |
Draws a diagonal line. o=orientation (R=right-leaning, L=left-leaning). |
^GE |
Graphic Ellipse | ^GEw,h,t,c |
Draws an ellipse with specified width, height, and border thickness. |
^GF |
Graphic Field | ^GFa,b,c,d,data |
Embeds a bitmap graphic (ASCII hex or Z64 encoded). a=format (A=ASCII hex), b=data bytes, c=total bytes, d=row width. |
Graphic Box Example
^XA
^FO30,30
^GB400,200,3,B,5 ← 400×200 box, 3-dot border, black, 5-dot rounded corners
^FO50,80
^A0N,40,40
^FDBoxed Text^FS
^XZTips & Common Gotchas
Dot units, not pixels
ZPL coordinates are in dots, not pixels. At 203 DPI (standard Zebra), 1 inch = 203 dots. At 300 DPI, 1 inch = 300 dots. When you render at higher DPI via Printivo, coordinates automatically scale.
^BY must precede the barcode
^BY sets bar width for the next barcode command. Place it immediately before ^BC, ^B3, etc. It does not apply to QR codes (^BQ).
Always close with ^FS
Every ^FD must be followed by ^FS. Missing ^FS is the most common cause of garbled or truncated labels.
QR code data via ^FD
For ^BQ, the data format is ^FDMA,your-data^FS where M=model, A=error correction. Example: ^FDMM,Ahttps://example.com^FS.
Case sensitivity
ZPL commands are case-insensitive. ^xA and ^XA are equivalent. Parameter values (like Y/N for print interpretation) are also case-insensitive.
Default DPI in Printivo
Printivo renders at 203 DPI by default, matching the Zebra ZPL standard. Use the dpi API parameter to render at 300 or 600 DPI — all dot coordinates scale automatically.
Try ZPL Rendering for Free
Paste any ZPL code into the Label Viewer and see your label rendered instantly — no account required.