The Complete ZPL Command Reference: 50+ Commands Explained with Examples
ZPL (Zebra Programming Language) is a page-description language developed by Zebra Technologies. It is the dominant language for direct thermal and thermal transfer label printers worldwide, used by every major carrier, warehouse, and fulfillment center. If you work with shipping labels at any scale, you will encounter raw ZPL — and this reference will help you understand every command you are likely to see.
This guide assumes you are comfortable with basic programming concepts but have no prior ZPL experience.
Key Takeaway
Every ZPL label is wrapped between ^XA (start) and ^XZ (end). All fields are addressed by pixel coordinates from the top-left corner. A 4"×6" label at 203 DPI is 812×1218 pixels; at 300 DPI it is 1200×1800 pixels.
Label Structure Commands
These commands define the physical dimensions, origin, and media settings of the label itself. They should appear near the top of the label, after ^XA.
^XA and ^XZ — Label Start and End
zpl^XA ... all label commands go here ... ^XZ
^XA marks the start of a label format. ^XZ marks the end and triggers the print. Everything outside this pair is ignored. For multi-label print jobs, you simply repeat the ^XA ... ^XZ block.
^LL — Label Length
zpl^LL1218
Sets the label length in dots. For a 6-inch label at 203 DPI: ^LL1218. For the same label at 300 DPI: ^LL1800. If omitted, the printer uses its last stored value. Always set this explicitly in programmatically generated labels to avoid surprises.
^PW — Print Width
zpl^PW812
Sets the printable width in dots. A 4-inch label at 203 DPI is 812 dots wide. This tells the printer how wide the format is and prevents it from clipping content.
^LH — Label Home
zpl^LH30,20
Shifts the entire coordinate origin by X,Y dots. Useful for compensating for label stock that doesn't start exactly at position 0,0 due to gaps or backing. Unlike ^FO, which positions individual fields, ^LH shifts everything on the label uniformly.
^LT — Label Top
zpl^LT10
Adjusts the vertical start position of the label in dot rows (range: -120 to 120). Used to fine-tune label alignment on the media.
^MT — Media Type
zpl^MTT
Sets media type: T for thermal transfer (ribbon), D for direct thermal. This affects how the printer applies heat and impacts darkness settings.
^MN — Media Tracking
zpl^MNN
Sets media tracking method: N for continuous (no gaps), Y for web sensing (gap between labels), M for mark sensing (black mark), A for auto-detect. Use ^MNA on new setups and let the printer calibrate with ^JUS.
^PQ — Print Quantity
zpl^PQ10,0,1,Y
Parameters: quantity, pause_count, replicates_per_serial, override. ^PQ10 prints 10 copies. ^PQ10,0,1,Y prints 10 copies and overrides pause mode. For batch printing 100+ labels programmatically, set this at the end of each label.
^PR — Print Rate (Speed)
zpl^PR4,4,4
Sets print speed in inches-per-second: print_speed, slew_speed, backfeed_speed. Valid values depend on the printer model (typically 2–14 IPS). Slower speeds improve print quality; faster speeds increase throughput.
Field and Text Commands
These commands control where content is placed on the label and how text is rendered.
Field Positioning
^FO — Field Origin
zpl^FO50,100 ^FDShip To:^FS
Sets the X,Y origin (in dots) for the next field. ^FO50,100 places the field 50 dots from the left and 100 dots from the top. All subsequent ^FD/^BC/^GB etc. commands use this as their starting point until the next ^FO.
^FP — Field Parameter (Direction)
zpl^FP
Rarely used standalone; it often appears as part of field rotation or positioning in legacy ZPL. Prefer ^FW for rotation.
^FW — Field Orientation (Rotation)
zpl^FWR
Rotates all subsequent fields: N = normal, R = rotated 90° clockwise, I = inverted 180°, B = rotated 270°. Use this to print vertical text along the edge of a label.
^FR — Reverse Field
zpl^FO50,50 ^FR ^A0N,30,30 ^FDWARNINg^FS
Inverts the colors of the field — black becomes white, white becomes black. Often used for white text on a black background box. Place ^FR immediately before the ^FD.
Text and Font Commands
^A — Scalable/Bitmapped Font
zpl^A0N,40,40 ^FDTracking Number^FS
^A0N,height,width uses the Zebra built-in scalable font (font 0). The N means normal orientation. Height and width are in dots. Built-in fonts: 0 (scalable), A–Z (bitmapped). For most modern labels, ^A0N with explicit dimensions is the right choice.
^CF — Default Font
zpl^CF0,30,30
Sets the default font so you don't have to repeat ^A before every field. ^CF0,30,30 makes the scalable font at 30×30 dots the default for all subsequent ^FD fields that don't specify their own font.
^CI — Change International Font/Encoding
zpl^CI28
Sets the character encoding. ^CI28 selects UTF-8, which enables printing accented characters, non-Latin scripts, and special symbols. Default is ^CI0 (standard ASCII). For international shipping labels, always set ^CI28 near the top of the label.
^FX — Comment Field
zpl^FXThis field is intentionally left blank^FS
^FX is a non-printing comment. Everything between ^FX and ^FS is ignored by the printer. Use it to document sections of your ZPL or to temporarily disable fields during debugging.
^FN — Field Name
zpl^FN1 ^FDAmazon.com^FS
Names a field for use with variable data printing (VDP). ^FN1 assigns number 1 to this field. You can then re-send just the variable fields (using ^XF or the ^FV command) without re-sending the entire template, which dramatically speeds up batch printing.
^FV — Field Variable
zpl^FV"B07ABCDE12"
Used in conjunction with ^FN. Supplies a value for a previously named field in a stored format. This is the basis of Zebra's "Fill in the blanks" printing — store the template once, then stream ^FN/^FV pairs to print variable data efficiently.
Barcode Commands
^BY — Bar Code Field Default
zpl^BY2,3.0,80
Sets barcode defaults: module_width, wide_to_narrow_ratio, bar_height. ^BY2,3.0,80 means: 2-dot module width, 3:1 wide-to-narrow ratio, 80-dot bar height. This affects all barcodes that follow until reset. Always set ^BY before your first barcode command.
^BC — Code 128 Barcode
zpl^FO50,200 ^BY2,3.0,100 ^BCN,100,Y,N,N ^FD>:1Z9999W9999W999^FS
^BCN,100,Y,N,N parameters: orientation(N), height(100 dots), print_HRI(Y = human-readable text below), print_check_digit(N), mode(N = auto). Code 128 is used for UPS, FedEx, and Amazon carrier labels. The >: prefix in ^FD selects Code 128 subset C (numeric pairs), which is optimal for long numeric strings.
^B3 — Code 39 Barcode
zpl^FO50,350 ^BY2,3.0,80 ^B3N,N,80,Y,N ^FDFNSKU-B07XYZ^FS
^B3N,N,80,Y,N: orientation, check_digit, height, HRI, start_stop_characters. Code 39 encodes uppercase letters, digits, and a few symbols. It is less dense than Code 128 but widely supported in older warehouse systems.
^BX — Data Matrix Barcode
zpl^FO50,500 ^BXN,4,200 ^FDB07ABCDE12-FNSKU-US^FS
^BXN,4,200: orientation(N), module_size(4 dots), data_columns(200). Data Matrix is a 2D barcode. Amazon uses it internally in some FC workflows. The data_columns parameter is a hint for symbol size selection — set it to 0 for auto-sizing.
^BQ — QR Code Barcode
zpl^FO50,650 ^BQN,2,5 ^FDQA,https://zentralabel.com^FS
^BQN,2,5: orientation, model(2 = Model 2, which is standard), magnification(5 = 5x module size). The ^FD value for QR codes requires a two-character mode prefix: QA = automatically selected error correction, or QH/QQ/QM/QL for specific levels (H=30%, Q=25%, M=15%, L=7%).
^B2 — Interleaved 2 of 5
zpl^FO50,800 ^BY2,3.0,60 ^B2N,60,Y ^FD0123456789^FS
Encodes digit pairs. Used in older logistics systems. The string must have an even number of digits. Not commonly seen in modern label workflows, but still encountered in legacy WMS integrations.
Graphics and Drawing Commands
^GB — Graphic Box
zpl^FO0,0 ^GB812,80,80,,0 ^FS
Draws a rectangle. Parameters: width, height, border_thickness, color(B=black/W=white), corner_rounding(0-8). ^GB812,80,80 draws a solid black bar spanning the full label width — commonly used for header bands. ^GB100,100,2 draws a 2-dot-thick hollow box.
^GE — Graphic Ellipse
zpl^FO300,400 ^GE100,100,3,B ^FS
Draws an ellipse: width, height, border_thickness, color. ^GE100,100 draws a circle with 100×100 dot bounding box.
^GF — Graphic Field (Image Data)
zpl^FO100,100 ^GFA,1000,1000,25,FFFFFFFFFFFFFFFF... ^FS
Embeds binary or ASCII-hex image data directly in the ZPL. Parameters: format(A=ASCII hex/B=binary), data_length, total_bytes, bytes_per_row, data. This is how logos and icons are embedded in labels. For large images, use ^XGM with stored graphics instead.
Printer Configuration Commands
^JN — Just Now Configuration
zpl^JN
Resets the printer configuration to factory defaults for the current session (does not write to flash). Useful at the start of a test label to ensure a clean state.
^JUS — Just Update Settings
zpl^XA^JUS^XZ
Saves current settings to flash memory, making them persistent across power cycles. Critical after calibrating media — always follow calibration commands with ^JUS. The typical calibration sequence is ^XA^JUS^XZ after loading new media.
^JMA — Just Mark Auto
zpl^XA^JMA^XZ
Triggers auto-detection of media type (gap, black mark, continuous). The printer advances media to sense it. Follow with ^JUS to persist the result.
^PM — Peel Mode
zpl^PMY
Enables peel-off mode (Y) on printers equipped with a peeler accessory. When enabled, the printer pauses after printing each label, waits for the label to be removed from the peeler, then prints the next. Set ^PMN to disable.
^PW — Print Width
zpl^PW812
Covered above under Label Structure. Included here as a reminder that it doubles as a printer calibration setting — setting it incorrectly clips printed content.
Advanced Field Modifiers
^FP — Field Parameter
zpl^FO50,100 ^FPH,2 ^A0N,30,30 ^FDLine 1^FS
Controls field padding and justification relative to the field origin. Less commonly needed in basic labels but useful for table-style layouts.
Full Working Label Example
The following is a complete, production-ready Amazon FBA box label in ZPL at 203 DPI (4"×6" label):
zpl^XA ^CI28 ^PW812 ^LL1218 ^LH0,0 ^MTD ^PR4,4,4 ^FO0,0 ^GB812,100,100,,0 ^FS ^FO20,15 ^FR ^CF0,60,60 ^FDAmazon Fulfillment^FS ^CF0,30,30 ^FO20,120 ^FDShip To:^FS ^FO20,155 ^A0N,35,35 ^FDAmazon.com - PHX6^FS ^FO20,195 ^FD800 W Buckeye Rd, Phoenix, AZ 85043^FS ^FO20,260 ^FDSold By:^FS ^FO20,295 ^FDYour Company Name^FS ^FO20,335 ^FDASIN: B07ABCDE12^FS ^FO50,390 ^BY2,3.0,120 ^BCN,120,Y,N,N ^FD>;B07ABCDE12-FNSKU^FS ^FO20,560 ^FDContents: 1 Unit^FS ^FO20,600 ^FDWarning: Use No Hooks^FS ^FO0,650 ^GB812,3,3,,0 ^FS ^FO20,660 ^FDShipment ID: FBA12345678^FS ^FO20,700 ^FDBox 1 of 1^FS ^FO20,750 ^BY2,3.0,80 ^BCN,80,Y,N,N ^FDFBA12345678^FS ^PQ1 ^XZ
This label uses a solid black header band (^GB) with reversed white text (^FR), two Code 128 barcodes (^BC), and explicit font sizing throughout. It will render correctly on any 203 DPI Zebra printer.
Key Takeaway
Paste this ZPL into Zentralabel to instantly preview it as a high-resolution PDF before sending it to a printer. This catches layout errors before you waste label stock.
Quick Reference and Tools
Quick Reference Table
| Command | Purpose | Key Parameters |
|---|---|---|
^XA / ^XZ | Label start / end | — |
^LL | Label length (dots) | length |
^PW | Print width (dots) | width |
^LH | Label home origin offset | x, y |
^LT | Label top offset | offset |
^MT | Media type | T, D |
^MN | Media tracking | N, Y, M, A |
^PQ | Print quantity | qty, pause, reps, override |
^PR | Print/slew/backfeed speed | speed, speed, speed |
^FO | Field origin | x, y |
^FW | Field orientation (rotation) | N, R, I, B |
^FR | Reverse (invert) field | — |
^FX | Comment (non-printing) | any text |
^FN | Field name (VDP) | number |
^FV | Field variable value (VDP) | value |
^A | Font selection | font, orientation, height, width |
^CF | Default font | font, height, width |
^CI | Character encoding | 0=ASCII, 28=UTF-8 |
^BY | Barcode defaults | module_width, ratio, height |
^BC | Code 128 barcode | orientation, height, HRI, check, mode |
^B3 | Code 39 barcode | orientation, check, height, HRI, startstop |
^BX | Data Matrix 2D barcode | orientation, module_size, columns |
^BQ | QR Code | orientation, model, magnification |
^GB | Graphic box | width, height, thickness, color, rounding |
^GE | Graphic ellipse | width, height, thickness, color |
^GF | Graphic field (embedded image) | format, length, total, bytes_per_row, data |
^JN | Reset to factory defaults (session) | — |
^JUS | Save settings to flash | — |
^JMA | Auto-detect media type | — |
^PM | Peel mode | Y, N |
Tools for Testing ZPL
Writing ZPL by hand and debugging it without a printer is painful. The Labelary online viewer (labelary.com/viewer.html) renders ZPL in a browser for free, though it has accuracy gaps with some advanced commands and doesn't support batch rendering. Zentralabel handles batch ZPL-to-PDF conversion with accurate rendering, making it practical for verifying entire shipment manifests before they reach your 3PL.
For sending raw ZPL to a printer from Windows, open a Command Prompt and run:
batchcopy /b yourlabel.zpl \\PRINTSERVER\ZebraPrinter
Or from Linux/macOS:
bashlpr -P ZebraPrinter -l yourlabel.zpl
The -l flag passes the file as raw data, bypassing the OS print driver's rendering.
