Step-by-step tutorial with 10 practical examples to create professional labels from scratch
Try our free ZPL tools right now
Free, runs in your browser — Instant results
ZPL (Zebra Programming Language) is the standard language for programming Zebra thermal printers and is used by major marketplaces like Amazon, eBay, and Shopify, as well as carriers like FedEx and UPS, to generate shipping labels. Compatible thermal printers include Zebra, Brother, DYMO, and Rollo models. In this tutorial you will learn to create ZPL labels from scratch in 10 progressive steps, from the basic structure to a complete shipping label. Each step includes code you can copy and test directly in the ZPLPDF ZPL Viewer. You do not need a Zebra printer: you can convert your ZPL code to PDF and print from any printer.
Every ZPL label starts with ^XA (start format) and ends with ^XZ (end format). Between these commands all elements are defined. Each element (text, barcode, graphic) is a "field" defined with ^FO (position), the content, and ^FS (end of field). This structure is mandatory — without ^XA/^XZ the printer will ignore the code. This is the minimum valid ZPL label you can create.
^XA ^FO50,50 ^A0N,30,30 ^FDHello World^FS ^XZ
Use ^LL to set the label length and ^PW to set the print width, both in dots. At 203 DPI: 1 inch = 203 dots, 1 mm = 8 dots. A standard 4x6 inch shipping label (used by Amazon, FedEx, UPS, and eBay) needs ^PW812 ^LL1218. The ^LH command adjusts the origin (margins) of the entire label. Always set size before placing any elements.
^XA ^PW812 ^LL1218 ^LH10,10 ^FO50,50^A0N,30,30 ^FD4x6 Inch Label^FS ^XZ
The ^FO (Field Origin) command defines the X,Y coordinates where the next element will be placed. Coordinates are measured in dots from the top-left corner of the label. X grows to the right, Y grows downward. At 203 DPI, 100 dots is approximately 12.5 mm. You can place multiple elements at different positions within the same label. Use the ZPLPDF viewer to visually adjust positions.
^XA ^FO50,30^A0N,25,25^FDTop left^FS ^FO300,30^A0N,25,25^FDTop right^FS ^FO50,200^A0N,25,25^FDBottom left^FS ^FO300,200^A0N,25,25^FDBottom right^FS ^XZ
The ^A command defines the font to use. Format: ^A(font)(orientation),(height),(width). Font 0 is the standard built-in font. Orientations: N=normal, R=90°, I=180°, B=270°. Height and width are measured in dots. For multi-line text with automatic word wrap, use ^FB(width),(lines),(spacing),(alignment) before ^FD. This is useful for addresses and long descriptions on Shopify or eBay order labels.
^XA ^FO50,30^A0N,50,50^FDLarge Title^FS ^FO50,100^A0N,30,30^FDMedium subtitle^FS ^FO50,150^A0N,20,20^FDSmall text^FS ^FO50,200^A0R,30,30^FDRotated 90°^FS ^FO50,300^FB400,3,0,C,0 ^A0N,25,25^FDThis text wraps automatically in a 400-dot wide block^FS ^XZ
To create a barcode, first configure its size with ^BY(module_width,ratio,height), then use the barcode type command. ^BC creates Code 128, the standard in logistics used by FedEx, UPS, Amazon, and eBay. Parameters of ^BC: orientation, height, human_readable(Y/N), text_above(Y/N), checksum(Y/N). Always use Y for human readable so the number is visible under the bars.
^XA ^FO50,50^BY2,3,100 ^BCN,100,Y,N,N ^FD123456789^FS ^FO50,200^BY3 ^BCN,80,Y,N,N ^FDABC-001-XYZ^FS ^XZ
The ^BQ command creates QR codes. Format: ^BQ(orientation),(model),(magnification). Always use model 2 and adjust magnification (1-10) for the desired size. Data must be preceded by two characters before the comma: the first is the error-correction level (H/Q/M/L) and the second is the input mode (A = automatic encoding, M = manual segments). Use HA, as the recommended default — H-level error correction (~30% recovery) plus automatic encoding. For UTF-8 / international characters, add ^CI28 before the ^BQ instead of switching prefix. Magnification 5 is a good starting point for standard labels.
^XA ^FO50,50 ^BQN,2,5 ^FDHA,https://zplpdf.com^FS ^FO350,50 ^BQN,2,3 ^FDHA,Product: SKU-001^FS ^XZ
The ^GB command draws boxes and rectangles: ^GB(width,height,line_thickness). If width and height equal the thickness, it draws a line. Use boxes to create frames, dividers, and visually organize label elements. You can also create circles with ^GC(diameter,thickness) and diagonal lines with ^GD. Structured layouts are common on professional shipping labels for FedEx, UPS, and carrier labels.
^XA ^FO30,30^GB500,300,2^FS ^FO30,120^GB500,1,1^FS ^FO50,50^A0N,30,30^FDHeader^FS ^FO50,140^A0N,25,25^FDLabel content here^FS ^FO50,200^A0N,25,25^FDMore information^FS ^FO400,250^GC50,2,B^FS ^XZ
By default, ZPL does not support accented characters or special symbols. To enable them, add ^CI28 at the beginning of your label to activate UTF-8 encoding. This is essential for labels with non-ASCII characters, international addresses, or product names containing special symbols. Without ^CI28, accents will appear as incorrect symbols. This is commonly needed for international Shopify orders or Amazon global marketplace labels.
^XA ^CI28 ^FO50,50^A0N,30,30 ^FDCustomer: Renée Müller^FS ^FO50,100^A0N,30,30 ^FDAddress: 123 Ñoño St.^FS ^FO50,150^A0N,30,30 ^FDCode: Ü-2024-US^FS ^XZ
The ^PQ(quantity) command before ^XZ defines how many copies to print. For automatic serialization (numbers that increment with each copy), use ^SN(start,increment,zero_fill) inside the field. This is ideal for generating labels with consecutive serial numbers without sending each label individually. Brother, DYMO, and Rollo printers all support the ^PQ command.
^XA ^FO50,50^A0N,30,30 ^FDProduct: Widget Pro^FS ^FO50,100^A0N,25,25 ^FDSerial: ^FS ^FO130,100^A0N,25,25 ^SN0001,1,Y^FS ^FO50,150^BY2^BCN,80,Y ^FDSKU-WIDGET-PRO^FS ^PQ5 ^XZ
This example combines all tutorial concepts into a real shipping label: size configuration, box frames, text at different sizes, Code 128 barcode for the tracking number, QR code with tracking URL, and UTF-8 support for international characters. You can use this as a base template for your Amazon, eBay, Shopify, FedEx, or UPS shipping labels. Compatible with Zebra ZT, ZD, GX series, as well as Brother, DYMO, and Rollo thermal printers.
^XA ^CI28 ^PW812^LL609 ^FO20,20^GB772,569,2^FS ^FO20,100^GB772,1,1^FS ^FO20,300^GB772,1,1^FS ^FO40,35^A0N,40,40^FDExpress Shipping^FS ^FO40,120^A0N,25,25^FDFrom: John Smith^FS ^FO40,155^A0N,25,25^FD123 Main St, Suite 456^FS ^FO40,190^A0N,25,25^FDNew York, NY 10001^FS ^FO40,240^A0N,30,30^FDTo: Jane Doe^FS ^FO40,275^A0N,25,25^FDLos Angeles, CA 90001^FS ^FO40,320^BY2^BCN,120,Y ^FDTRACKING-2024-001234^FS ^FO600,320^BQN,2,4 ^FDHA,https://track.example.com/001234^FS ^FO40,470^A0N,20,20^FDWeight: 2.5 lbs | 1 of 1^FS ^XZ
Use our ZPL viewer to see how your label will look before printing. No printer needed.