How to Create ZPL Labels
Step-by-step tutorial with 10 practical examples to create professional labels from scratch
Try our free ZPL tools right now
Free, no signup required — Instant results
Introduction to ZPL
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.
1Step 1: Basic structure of a ZPL label
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
2Step 2: Configuring label size with ^LL and ^PW
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
3Step 3: Positioning elements with ^FO
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
4Step 4: Text with different fonts and sizes
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
5Step 5: Barcodes with ^BY and ^BC (Code 128)
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
6Step 6: QR Codes with ^BQ
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 a prefix: QA for automatic detection, or MM,A for data with special characters. Magnification 5 is a good starting point for standard labels. QR codes are commonly used on Shopify packing slips and product tracking labels.
^XA ^FO50,50 ^BQN,2,5 ^FDQA,https://zplpdf.com^FS ^FO350,50 ^BQN,2,3 ^FDQA,Product: SKU-001^FS ^XZ
7Step 7: Drawing boxes, lines, and dividers with ^GB
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
8Step 8: Special characters and accents with ^CI28
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
9Step 9: Printing multiple copies with ^PQ
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
10Step 10: Complete shipping label
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 ^FDQA,https://track.example.com/001234^FS ^FO40,470^A0N,20,20^FDWeight: 2.5 lbs | 1 of 1^FS ^XZ
Tips for creating ZPL labels
- Always test your code in the ZPLPDF ZPL Viewer before sending to the printer
- Add ^CI28 at the start if you need accents, special symbols, or international characters
- Use ^BY BEFORE each barcode to control bar width and height
- For standard 4x6 inch shipping labels (Amazon, FedEx, UPS): use ^PW812 ^LL1218 at 203 DPI
- ^FO coordinates are measured in dots: at 203 DPI, 1 inch = 203 dots, 1 mm = approximately 8 dots
- Use ^FB to create multi-line text blocks with automatic word wrapping
- Organize your label visually with ^GB to create frames and divider lines
- Save reusable templates and only change variable data — use ^FN fields for batch label runs
- Validate your code with the ZPL Validator to catch syntax errors before printing
- If you do not have a Zebra, Brother, DYMO, or Rollo printer, convert your ZPL to PDF with ZPLPDF and print from any printer
Frequently asked questions about creating ZPL labels
Do I need a Zebra printer to use ZPL code?
What size is a standard shipping label?
How do I calculate coordinates to position elements?
Why do my special characters or accents appear as garbled symbols?
How do I create labels with variable data (name, address, tracking number)?
Can I create ZPL labels from a spreadsheet or database?
How do I print multiple different labels in a single print job?
Test your ZPL code now
Use our ZPL viewer to see how your label will look before printing. No printer needed.