In ZPL (Zebra Programming Language), ^XA marks the start of a label format and ^XZ marks its end. Every valid label sent to a Zebra printer must open with ^XA and close with ^XZ; nothing outside those two commands is treated as part of the label. Label Toolkit's browser-based ZPL export wraps every design in this pair automatically, so your output is always structurally correct.
- ^XA tells the printer to begin a new label format and clears the format buffer.
- ^XZ tells the printer the format is complete and triggers label printing.
- All other ZPL commands, including field origins (
^FO), field data (^FD), barcodes (^BC), and fonts (^A0), must appear between these two delimiters. - Forgetting either delimiter is the single most common cause of a Zebra printer receiving data but printing nothing.
What exactly do ^XA and ^XZ mean?
The caret (^) is ZPL's command prefix character. XA stands for "format start" (think of it as "eXecute A label") and XZ stands for "format end." Together they define a label format, which is the complete set of instructions Zebra firmware needs to render one or more identical labels.
When the printer's firmware receives ^XA, it allocates a format buffer and begins parsing subsequent bytes as ZPL commands. When it receives ^XZ, it commits the buffer, renders the image at the configured DPI (dots per inch, also expressed as dpmm, dots per millimeter), and feeds the label. A 203 dpi printer produces approximately 8 dots per millimeter; a 300 dpi printer produces roughly 12 dots per millimeter. The physical dot size affects minimum readable barcode widths and text legibility, but ^XA/^XZ themselves are DPI-agnostic.
For a broader orientation to the language, see the complete guide to ZPL II before working through individual commands.
The minimal valid ZPL label
The shortest syntactically valid ZPL document is just two lines:
^XA
^XZ
This prints a blank label. It is useful for advancing (feeding) media without printing content, for example when calibrating label gap sensors.
A real working label with text and a barcode
Below is a complete, copy-paste ZPL format that prints a human-readable line of text and a Code 128 barcode on a 4 inch x 2 inch (101.6 mm x 50.8 mm) label at 203 dpi. Coordinates are in dots (1 dot = 1/203 inch at 203 dpi).
^XA
^FO50,30^A0N,40,30^FDShip-To: Warehouse B^FS
^FO50,90^BY2^BCN,80,Y,N,N^FD123456789012^FS
^XZ
Command-by-command breakdown:
^XAopens the format.^FO50,30sets the field origin to x=50 dots, y=30 dots from the top-left corner.^A0N,40,30selects the scalable font (font 0), orientation Normal, height 40 dots, width 30 dots.^FD...^FSwraps the field data between "field data" start and "field separator" end.^FO50,90moves down to y=90 dots for the barcode row.^BY2sets the barcode module width to 2 dots (the narrowest bar).^BCN,80,Y,N,Nprints a Code 128 barcode: Normal orientation, 80 dots tall, with a human-readable interpretation line below.^FD123456789012^FSsupplies the barcode data and closes the field.^XZcloses the format and fires the print.

Rules and edge cases you need to know
Can you use lowercase? Does whitespace matter?
ZPL commands are case-sensitive. ^xa is not the same as ^XA. Many Zebra printers accept ^xa in practice, but the Zebra ZPL II Programming Guide specifies uppercase, and relying on lowercase is fragile across firmware versions. Always use uppercase.
Whitespace (spaces, tabs, newlines) between commands is ignored by the parser. You can write the entire format on one line or spread it across many lines for readability. Neither approach affects the printed output.
Can you nest multiple ^XA...^XZ blocks?
No. You cannot nest one format inside another. If the printer encounters a second ^XA before it sees ^XZ, firmware behavior varies by model, but most printers treat the second ^XA as an implicit close of the previous format and a start of a new one. This can result in partial or missing labels. Always close every format with ^XZ before opening a new ^XA.
Printing multiple copies of the same label
You do not repeat ^XA...^XZ to get multiple copies. Instead, use the ^PQ (Print Quantity) command inside the format:
^XA
^FO50,30^A0N,40,30^FDProduct Label^FS
^PQ5,0,1,Y
^XZ
^PQ5,0,1,Y prints 5 copies, with 0 labels between cuts, 1 reprint on error, and Y meaning "override" for the cut behavior. This is far more efficient than sending five separate ^XA...^XZ blocks because the format is compiled once in firmware.
Stored (recalled) formats and ^XA
ZPL supports storing a format in printer memory using ^DF (Download Format) and recalling it later. When you recall a stored format and supply variable data, you still wrap the recall command in ^XA...^XZ. For example:

