Menu

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

ComandoDescripciónEjemploParámetros
^XAStart label format. Every ZPL code must begin with this command.^XA ... ^XZNo parameters
^XZEnd label format. Closes the block started with ^XA and sends the label to print.^XA ^FO50,50 ^FDHello^FS ^XZNo parameters
^FOField origin. Sets the X,Y position where the next element (text, barcode, graphic) will be placed.^FO100,200x,y - Coordinates in dots. 203 dpi = 8 dots/mm
^FTField typeset. Similar to ^FO but positions from the text baseline, useful for aligning text of different sizes.^FT100,200x,y - Coordinates from text baseline
^FSField separator. Marks the end of an individual field. Every field (text, barcode, graphic) must end with ^FS.^FO50,50^FDText^FSNo parameters
^CIChange international encoding. Enables special characters like accents (á, é, ñ) and symbols in your labels.^CI28code - 28 = UTF-8, 13 = Latin-1. Use ^CI28 for international characters
^CFDefault font. Sets the default font, orientation and size for the entire label.^CF0,30,30font,height,width - Font 0 is the standard built-in font
^FWDefault field orientation. Sets the default rotation for text and barcodes.^FWRN=Normal, R=90°, I=180°, B=270°

Text commands

ComandoDescripciónEjemploParámetros
^AFont selection and size. Defines which font to use and its size for the next text field.^A0N,30,30f,o,h,w - f=Font (0-9,A-Z), o=Orientation (N,R,I,B), h=Height, w=Width
^FDField data. The text or data to print. Always goes after ^FO and ^A, and before ^FS.^FO50,50^A0N,30,30^FDMy text^FStext - Content to print (max 3072 characters)
^FBMultiline 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^FSwidth,max_lines,spacing,alignment(L/C/R/J),indent
^FHHex indicator. Allows inserting special characters using their hex code preceded by _ (underscore).^FH^FDPrice: _c2_a250.00^FSindicator - Defaults to _ as hex prefix
^FNField number for templates. Creates numbered fields that can be filled later, useful for variable-data labels.^FO50,50^A0N,30,30^FN1^FSnumber - Field number (1-999) for replacement
^SNNumeric serialization. Automatically increments a number on each printed label, ideal for serial numbers or batch codes.^FO50,50^A0N,30,30^SN001,1,Y^FSstart,increment,zero_pad(Y/N)

Barcode commands

ComandoDescripciónEjemploParámetros
^BYBarcode field default. Sets the module width, ratio and default height. Must go BEFORE the barcode command.^BY2,3,100module_width(1-10),ratio(2.0-3.0),height - Width controls resolution
^BCCode 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^FSo,height,interpretation(Y/N),above(Y/N),checksum(Y/N)
^BQQR Code. Encodes URLs, long text or binary data. Widely used in tracking labels and marketing.^FO50,50^BQN,2,5^FDQA,https://example.com^FSo,model(1/2),magnification(1-10). Data prefix: QA=auto, QM=manual
^BEEAN-13 — Global standard for retail products. Requires exactly 12 digits (13th is automatic checksum).^FO50,50^BY2^BEN,100,Y,N^FD750123456789^FSo,height,interpretation(Y/N),above(Y/N)
^BUUPC-A — Standard for US and Canadian retail. Requires exactly 11 digits (12th is checksum).^FO50,50^BY2^BUN,100,Y,N^FD12345678901^FSo,height,interpretation(Y/N),above(Y/N)
^B3Code 39 — Widely used in inventory and manufacturing. Encodes uppercase letters, numbers and some symbols only.^FO50,50^BY2^B3N,N,100,Y,N^FDABC123^FSo,checksum(Y/N),height,interpretation(Y/N),above(Y/N)
^BXDataMatrix — 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^FSo,height,quality(0-200). 200=maximum error correction
^B7PDF417 — High-capacity 2D code. Used in driver licenses, boarding passes and identity documents.^FO50,50^B7N,5,2,3,10,N^FDExtended data here^FSo,height,security(0-8),columns,rows,truncated(Y/N)
^BOAztec — Compact 2D code with no quiet zone required. Used in transport tickets and space-constrained applications.^FO50,50^BON,5,N^FDAztec Data^FSo,magnification,ECL(Y/N). No white zone required around it

Graphic and line commands

ComandoDescripciónEjemploParámetros
^GBDraw box or rectangle. Creates borders, dividers and frames to visually organize the label.^FO50,50^GB400,200,3^FSwidth,height,line_thickness,color(B/W),rounding(0-8)
^GCDraw circle. Creates a circle with the specified diameter and line thickness.^FO50,50^GC100,3,B^FSdiameter,line_thickness,color(B/W)
^GDDraw diagonal line. Creates a line from the top-left corner to the bottom-right (or vice versa).^FO50,50^GD200,100,3,B,L^FSwidth,height,thickness,color(B/W),direction(L/R)
^GEDraw ellipse. Creates an ellipse with the specified width, height and border thickness.^FO50,50^GE200,100,3,B^FSwidth,height,line_thickness,color(B/W)
^GFGraphic 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

ComandoDescripciónEjemploParámetros
^LHLabel home. Shifts the reference point (0,0) for the entire label. Useful for adjusting margins.^LH30,20x,y - New origin in dots
^LLLabel length. Sets the total label length in dots. Required if the printer does not auto-detect label length.^LL800length - In dots. 203dpi: 800dots ≈ 100mm
^PWPrint width. Sets the maximum print width. Useful for centering content on narrow labels.^PW812width - In dots. 4" at 203dpi = 812 dots
^LTLabel top. Shifts the entire image up or down to calibrate vertical positioning.^LT10offset - Positive=down, negative=up (-120 to 120)
^LSLabel shift. Moves the entire image left or right for horizontal calibration.^LS-20offset - Positive=right, negative=left
^MNMedia tracking. Configures how the printer detects labels: by black mark, gap or continuous mode.^MNYN=Continuous, Y=Gap/Space, M=Black mark, W=Web sensing
^MMPrint mode. Controls whether the printer tears, peels or rewinds labels after printing.^MMTT=Tear-off, P=Peel-off, R=Rewind, C=Cutter, A=Applicator

Print commands

ComandoDescripciónEjemploParámetros
^PQPrint quantity. Sets how many copies to print of the current label. Supports pause between groups.^PQ3,0,1,Yquantity,pause_between_groups,copies_per_group,override(Y/N)
^PRPrint rate (speed). Controls print, backfeed and feed speeds. Lower speed = better quality.^PR4,4,4print(1-14),backfeed,feed - Speed in inches/second
^PMPrint mirror. Flips the entire image horizontally. Useful for printing on transparent materials.^PMYY=Mirror enabled, N=Normal
^POPrint orientation. Rotates the entire label 180° for printers that feed from below.^POIN=Normal, I=Inverted (180°)

Printer configuration commands (~)

ComandoDescripciónEjemploParámetros
~SDSet darkness. Adjusts print intensity. Higher values = darker output, more ribbon usage.~SD15value (0-30) - Recommended: 10-20 for thermal transfer
~JACancel all jobs. Stops the current print and clears the printer buffer.~JANo parameters
~HSHost status. Requests printer status information: paper, ribbon, active errors.~HSNo parameters - Returns 3 lines of status
~DGDownload graphic. Stores an image in the printer memory for repeated use without resending data.~DGR:LOGO.GRF,bytes,width,dataname,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.