ZPL Command Reference

Learn about Zebra Programming Language (ZPL) commands supported by Printivo's label renderer.

ZPL Basics

ZPL is a command language used to communicate with Zebra thermal printers. Commands start with a caret (^) or tilde (~) followed by two letters.

Label Structure

Every ZPL label follows this basic structure:

^XA          ; Start of label format
; ... commands here ...
^XZ          ; End of label format

Coordinate System

ZPL uses a coordinate system starting at the top-left corner (0,0). Units are in dots, where the number of dots per inch depends on the printer DPI:

  • 203 DPI: 8 dots per mm (~203 dots per inch)
  • 300 DPI: ~12 dots per mm (~300 dots per inch)
  • 600 DPI: ~24 dots per mm (~600 dots per inch)
Tip: Printivo defaults to 203 DPI (standard for most Zebra printers). Use the dpi parameter to change this.

Label Format Commands

^XA - Start Format

Marks the beginning of a label format. Required at the start of every label.

^XZ - End Format

Marks the end of a label format. Required at the end of every label.

^FO - Field Origin

Sets the position for the next element.

^FOx,y
; x = horizontal position in dots
; y = vertical position in dots

^FO100,50   ; Position at x=100, y=50

^FS - Field Separator

Ends the current field. Required after most field content.

^LH - Label Home

Sets the label home position (offset for all elements).

^LH0,0   ; Default, no offset
^LH50,50 ; Shift all elements 50 dots right and down

Text & Fonts

^FD - Field Data

Specifies the text data to print.

^FDHello World^FS

^A0 - Scalable Font

Sets the scalable/bitmap font for text.

^A0o,h,w
; o = orientation (N=normal, R=90°, I=180°, B=270°)
; h = character height in dots
; w = character width in dots

^A0N,50,50   ; Normal orientation, 50x50 dots
^A0R,30,30   ; Rotated 90°, 30x30 dots

^CF - Change Default Font

Sets the default font for subsequent fields.

^CF0,40   ; Font 0, height 40 dots

^FB - Field Block

Creates a text block with word wrapping.

^FBw,l,s,j,h
; w = block width in dots
; l = maximum lines
; s = line spacing (add/subtract dots)
; j = justification (L=left, C=center, R=right, J=justified)
; h = hanging indent

^FB400,3,0,C,0^FDThis text will wrap and center^FS

Barcodes

^BY - Bar Code Field Default

Sets default parameters for barcodes.

^BYw,r,h
; w = module width (1-10 dots)
; r = wide to narrow ratio (2.0-3.0)
; h = bar code height in dots

^BY3,2.5,100

^BC - Code 128 Barcode

Prints a Code 128 barcode.

^BCo,h,f,g,e,m
; o = orientation
; h = height in dots
; f = print interpretation line (Y/N)
; g = print above barcode (Y/N)
; e = UCC check digit (Y/N)
; m = mode (N=normal, U=UCC, A/D/Auto)

^FO100,100^BY3^BCN,100,Y,N,N^FD123456^FS

^B3 - Code 39 Barcode

Prints a Code 39 barcode.

^FO100,100^BY2^B3N,N,100,Y,N^FDABC123^FS

^BQ - QR Code

Prints a QR code.

^BQo,m,s
; o = orientation (N only)
; m = model (1 or 2, use 2)
; s = magnification (1-10)

^FO100,100^BQN,2,5^FDMA,https://example.com^FS

See the Barcode Types guide for a complete list of supported formats.

Graphics

^GB - Graphic Box

Draws a box or line.

^GBw,h,t,c,r
; w = width in dots
; h = height in dots
; t = border thickness
; c = line color (B=black, W=white)
; r = corner rounding (0-8)

; Rectangle
^FO50,50^GB200,100,3,B,0^FS

; Horizontal line
^FO50,200^GB300,3,3,B,0^FS

; Vertical line
^FO400,50^GB3,200,3,B,0^FS

^GE - Graphic Ellipse

Draws an ellipse or circle.

^GEw,h,t,c
; w = width in dots
; h = height in dots
; t = border thickness
; c = line color

; Circle
^FO100,100^GE100,100,3,B^FS

; Ellipse
^FO100,100^GE200,100,3,B^FS

^GD - Graphic Diagonal Line

Draws a diagonal line.

^GDw,h,t,c,d
; d = direction (L=left, R=right)

^FO100,100^GD200,200,3,B,R^FS

^FR - Field Reverse

Reverses the printing (white on black).

^FO100,100^GB200,60,60,B,0^FS
^FO110,115^FR^A0N,30,30^FDReversed^FS

Complete Examples

Shipping Label

^XA
^LH0,0

; Company logo area
^FO50,50^GB200,80,2^FS
^FO75,75^A0N,30,30^FDACMECorp^FS

; Divider line
^FO50,150^GB700,3,3^FS

; Ship To section
^FO50,170^A0N,25,25^FDSHIP TO:^FS
^FO50,210^A0N,40,40^FDJohn Doe^FS
^FO50,260^A0N,30,30^FD123 Main Street^FS
^FO50,300^A0N,30,30^FDNew York, NY 10001^FS

; Barcode
^FO500,200^BY3^BCN,100,Y,N,N^FD1234567890^FS

; QR Code
^FO550,350^BQN,2,5^FDMA,https://track.example.com/1234567890^FS

^XZ

Product Label

^XA

; Product name
^FO50,50^A0N,60,60^FDWidget Pro^FS

; Description
^FO50,130^FB600,2,0,L,0^A0N,25,25^FDHigh-quality widget for professional use. Made with premium materials.^FS

; Price
^FO50,220^A0N,80,80^FD$29.99^FS

; SKU barcode
^FO400,50^BY2^BCN,80,Y,N,N^FDSKU12345^FS

; Border
^FO40,40^GB720,320,2^FS

^XZ
Try it: Copy these examples and paste them in the Label Viewer to see the rendered output.
An unhandled error has occurred. Reload X