Most Common ZPL Commands
Complete reference of 40+ commands for Zebra printer programming with practical examples
Try our free ZPL tools right now
Free, no signup required — Instant results
ZPL Command Reference
ZPL (Zebra Programming Language) uses commands that begin with ^ (caret) or ~ (tilde). Commands with ^ are used within the label format, between ^XA and ^XZ. Commands with ~ are used for printer configuration and can be sent outside a format. Each command has optional parameters separated by commas. This guide covers the most commonly used commands for shipping labels, inventory, retail and logistics.
Command categories
Label format commands
| Comando | Descripción | Ejemplo | Parámetros |
|---|---|---|---|
| ^XA | Start label format. Every ZPL code must begin with this command. | ^XA ... ^XZ | No parameters |
| ^XZ | End label format. Closes the block started with ^XA and sends the label to print. | ^XA ^FO50,50 ^FDHello^FS ^XZ | No parameters |
| ^FO | Field origin. Sets the X,Y position where the next element (text, barcode, graphic) will be placed. | ^FO100,200 | x,y - Coordinates in dots. 203 dpi = 8 dots/mm |
| ^FT | Field typeset. Similar to ^FO but positions from the text baseline, useful for aligning text of different sizes. | ^FT100,200 | x,y - Coordinates from text baseline |
| ^FS | Field separator. Marks the end of an individual field. Every field (text, barcode, graphic) must end with ^FS. | ^FO50,50^FDText^FS | No parameters |
| ^CI | Change international encoding. Enables special characters like accents (á, é, ñ) and symbols in your labels. | ^CI28 | code - 28 = UTF-8, 13 = Latin-1. Use ^CI28 for international characters |
| ^CF | Default font. Sets the default font, orientation and size for the entire label. | ^CF0,30,30 | font,height,width - Font 0 is the standard built-in font |
| ^FW | Default field orientation. Sets the default rotation for text and barcodes. | ^FWR | N=Normal, R=90°, I=180°, B=270° |
Text commands
| Comando | Descripción | Ejemplo | Parámetros |
|---|---|---|---|
| ^A | Font selection and size. Defines which font to use and its size for the next text field. | ^A0N,30,30 | f,o,h,w - f=Font (0-9,A-Z), o=Orientation (N,R,I,B), h=Height, w=Width |
| ^FD | Field data. The text or data to print. Always goes after ^FO and ^A, and before ^FS. | ^FO50,50^A0N,30,30^FDMy text^FS | text - Content to print (max 3072 characters) |
| ^FB | Multiline field block. Creates a fixed-width text area that automatically wraps text across multiple lines. | ^FB400,3,0,L,0^FDLong text that wraps automatically^FS | width,max_lines,spacing,alignment(L/C/R/J),indent |
| ^FH | Hex indicator. Allows inserting special characters using their hex code preceded by _ (underscore). | ^FH^FDPrice: _c2_a250.00^FS | indicator - Defaults to _ as hex prefix |
| ^FN | Field number for templates. Creates numbered fields that can be filled later, useful for variable-data labels. | ^FO50,50^A0N,30,30^FN1^FS | number - Field number (1-999) for replacement |
| ^SN | Numeric serialization. Automatically increments a number on each printed label, ideal for serial numbers or batch codes. | ^FO50,50^A0N,30,30^SN001,1,Y^FS | start,increment,zero_pad(Y/N) |
Barcode commands
| Comando | Descripción | Ejemplo | Parámetros |
|---|---|---|---|
| ^BY | Barcode field default. Sets the module width, ratio and default height. Must go BEFORE the barcode command. | ^BY2,3,100 | module_width(1-10),ratio(2.0-3.0),height - Width controls resolution |
| ^BC | Code 128 — The most used in logistics and shipping. Encodes numbers, letters and special characters. Industry standard for parcels. | ^FO50,50^BY2^BCN,100,Y,N,N^FD123456789^FS | o,height,interpretation(Y/N),above(Y/N),checksum(Y/N) |
| ^BQ | QR Code. Encodes URLs, long text or binary data. Widely used in tracking labels and marketing. | ^FO50,50^BQN,2,5^FDQA,https://example.com^FS | o,model(1/2),magnification(1-10). Data prefix: QA=auto, QM=manual |
| ^BE | EAN-13 — Global standard for retail products. Requires exactly 12 digits (13th is automatic checksum). | ^FO50,50^BY2^BEN,100,Y,N^FD750123456789^FS | o,height,interpretation(Y/N),above(Y/N) |
| ^BU | UPC-A — Standard for US and Canadian retail. Requires exactly 11 digits (12th is checksum). | ^FO50,50^BY2^BUN,100,Y,N^FD12345678901^FS | o,height,interpretation(Y/N),above(Y/N) |
| ^B3 | Code 39 — Widely used in inventory and manufacturing. Encodes uppercase letters, numbers and some symbols only. | ^FO50,50^BY2^B3N,N,100,Y,N^FDABC123^FS | o,checksum(Y/N),height,interpretation(Y/N),above(Y/N) |
| ^BX | DataMatrix — Compact 2D code used in manufacturing, electronics and pharmaceuticals. Stores a lot of data in a small space. | ^FO50,50^BXN,5,200^FDSN:ABC123456^FS | o,height,quality(0-200). 200=maximum error correction |
| ^B7 | PDF417 — High-capacity 2D code. Used in driver licenses, boarding passes and identity documents. | ^FO50,50^B7N,5,2,3,10,N^FDExtended data here^FS | o,height,security(0-8),columns,rows,truncated(Y/N) |
| ^BO | Aztec — Compact 2D code with no quiet zone required. Used in transport tickets and space-constrained applications. | ^FO50,50^BON,5,N^FDAztec Data^FS | o,magnification,ECL(Y/N). No white zone required around it |
Graphic and line commands
| Comando | Descripción | Ejemplo | Parámetros |
|---|---|---|---|
| ^GB | Draw box or rectangle. Creates borders, dividers and frames to visually organize the label. | ^FO50,50^GB400,200,3^FS | width,height,line_thickness,color(B/W),rounding(0-8) |
| ^GC | Draw circle. Creates a circle with the specified diameter and line thickness. | ^FO50,50^GC100,3,B^FS | diameter,line_thickness,color(B/W) |
| ^GD | Draw diagonal line. Creates a line from the top-left corner to the bottom-right (or vice versa). | ^FO50,50^GD200,100,3,B,L^FS | width,height,thickness,color(B/W),direction(L/R) |
| ^GE | Draw ellipse. Creates an ellipse with the specified width, height and border thickness. | ^FO50,50^GE200,100,3,B^FS | width,height,line_thickness,color(B/W) |
| ^GF | Graphic field. Inserts a compressed image (hex or Z64 format). Used for logos, signatures and custom graphics. | ^GFA,compressed_data... | format(A=ASCII hex),data_bytes,bytes_per_row,rows,data |
Label setup commands
| Comando | Descripción | Ejemplo | Parámetros |
|---|---|---|---|
| ^LH | Label home. Shifts the reference point (0,0) for the entire label. Useful for adjusting margins. | ^LH30,20 | x,y - New origin in dots |
| ^LL | Label length. Sets the total label length in dots. Required if the printer does not auto-detect label length. | ^LL800 | length - In dots. 203dpi: 800dots ≈ 100mm |
| ^PW | Print width. Sets the maximum print width. Useful for centering content on narrow labels. | ^PW812 | width - In dots. 4" at 203dpi = 812 dots |
| ^LT | Label top. Shifts the entire image up or down to calibrate vertical positioning. | ^LT10 | offset - Positive=down, negative=up (-120 to 120) |
| ^LS | Label shift. Moves the entire image left or right for horizontal calibration. | ^LS-20 | offset - Positive=right, negative=left |
| ^MN | Media tracking. Configures how the printer detects labels: by black mark, gap or continuous mode. | ^MNY | N=Continuous, Y=Gap/Space, M=Black mark, W=Web sensing |
| ^MM | Print mode. Controls whether the printer tears, peels or rewinds labels after printing. | ^MMT | T=Tear-off, P=Peel-off, R=Rewind, C=Cutter, A=Applicator |
Print commands
| Comando | Descripción | Ejemplo | Parámetros |
|---|---|---|---|
| ^PQ | Print quantity. Sets how many copies to print of the current label. Supports pause between groups. | ^PQ3,0,1,Y | quantity,pause_between_groups,copies_per_group,override(Y/N) |
| ^PR | Print rate (speed). Controls print, backfeed and feed speeds. Lower speed = better quality. | ^PR4,4,4 | print(1-14),backfeed,feed - Speed in inches/second |
| ^PM | Print mirror. Flips the entire image horizontally. Useful for printing on transparent materials. | ^PMY | Y=Mirror enabled, N=Normal |
| ^PO | Print orientation. Rotates the entire label 180° for printers that feed from below. | ^POI | N=Normal, I=Inverted (180°) |
Printer configuration commands (~)
| Comando | Descripción | Ejemplo | Parámetros |
|---|---|---|---|
| ~SD | Set darkness. Adjusts print intensity. Higher values = darker output, more ribbon usage. | ~SD15 | value (0-30) - Recommended: 10-20 for thermal transfer |
| ~JA | Cancel all jobs. Stops the current print and clears the printer buffer. | ~JA | No parameters |
| ~HS | Host status. Requests printer status information: paper, ribbon, active errors. | ~HS | No parameters - Returns 3 lines of status |
| ~DG | Download graphic. Stores an image in the printer memory for repeated use without resending data. | ~DGR:LOGO.GRF,bytes,width,data | name,total_bytes,bytes_per_row,hex_data |
Frequently asked questions about ZPL commands
What are the essential ZPL commands for beginners?
The 6 must-know commands are: ^XA (label start), ^XZ (label end), ^FO (X,Y position), ^A (font and size), ^FD (text to print) and ^FS (end of field). With these 6 commands you can create basic text labels. For shipping labels, add ^BY (barcode setup) and ^BC (Code 128).
What is the difference between ^FO and ^FT in ZPL?
^FO (Field Origin) positions from the top-left corner of the element. ^FT (Field Typeset) positions from the text baseline. For most cases ^FO is more intuitive. Use ^FT when you need to align text of different sizes on the same baseline, as ^FT maintains vertical alignment regardless of font size.
How do I print special characters and accents in ZPL?
Use the ^CI28 command at the beginning of your label to enable UTF-8 encoding. Example: ^XA ^CI28 ^FO50,50 ^A0N,30,30 ^FDCafé — Résumé^FS ^XZ. Without ^CI28, special characters like á, é, ñ, ü will appear as incorrect symbols.
How do I print multiple copies of the same label?
Use the ^PQ command before ^XZ. Example: ^PQ5 prints 5 copies. For serialization (incrementing numbers), use ^SN within the field: ^FO50,50 ^A0N,30,30 ^SN001,1,Y^FS will print 001, 002, 003... on each successive copy.
Do ZPL commands work on non-Zebra printers?
Not directly. ZPL is native to Zebra printers only. Some brands like TSC and SATO have partial compatibility modes, but they are not 100% reliable. For other printer brands like Brother, DYMO, Rollo or generic thermal printers, the recommended solution is to convert ZPL to PDF using ZPLPDF and then print the PDF from any printer.
Which barcode type should I use for shipping labels?
Code 128 (^BC) is the global standard in logistics and parcel shipping. For marketplace labels like Amazon, eBay or Shopify, the barcode is already included in the ZPL they generate. If you need to create your own shipping barcode, use ^BY2 ^BCN,100,Y for a readable Code 128 with human-readable interpretation below.
How do I adjust print size and quality in ZPL?
For barcode resolution, adjust the first parameter of ^BY (module width): ^BY2 for standard, ^BY3 for thicker. For overall darkness, use ~SD followed by a value from 0-30 (15 recommended). For speed (lower = better quality), use ^PR followed by speed in inches/second: ^PR4 is a good quality/speed balance.
Validate your ZPL code
Use our validator to verify your ZPL code is correct before sending it to the printer.