ZPL guide 1 of 9

What is ZPL? The anatomy of a label

ZPL is a command language that thermal label printers read. See what a command looks like, how a label starts and ends, and build one small label step by step.

What ZPL is, and what it is not

Question What is ZPL, and why can it not be mixed with the settings language (SGD)?

ZPL is a text language for label printers. Instead of sending a finished picture of a label, you send a list of commands that say what goes where, and the printer follows them.

Zebra's reference guide documents two command sets for printer firmware side by side: ZPL commands and SGD (Set-Get-Do) commands. SGD commands set and get configuration details.p. 47

WarningThe guide says ZPL and SGD commands should be sent to the printer as separate files. Keep SGD commands out of your label formats.p. 47

Some settings can be changed through either language, and a configuration change made in ZPL can affect one made in SGD. If a setting will not stick, check what the other language did to it.p. 47

For G-Series printers, which can also accept EPL, the guide says EPL, ZPL and SGD must each go in their own file and cannot be combined in one format.p. 47

Anatomy of one command

Question What does a single command look like, and what is the difference between a caret and a tilde?

A command is a prefix character, a short command code, then its parameters. The guide documents each command with a Format line, for example ^BCo,h,f,g,e,m for Code 128: the caret, the code BC, and parameter letters that you replace with real values.pp. 48, 94

Parameters are separated by commas, and most have a documented default, though some commands insist on a value: ^FD has no default and ^MT is ignored without one. To keep a default, leave its slot empty and keep the comma; trailing defaults can be dropped altogether. For example, ^BC,80 sets only the second parameter of the Code 128 command.pp. 48, 94, 190, 311, 1765

The caret (^) is the default prefix for format commands, the commands that describe a label. The tilde (~) is the default prefix for control commands.pp. 152, 166

A control command is acted on as soon as the printer receives it, while a label format is printed when the closing ^XZ arrives. Use each command with the prefix the guide shows for it; a few commands are documented with both prefixes.pp. 152, 166, 375, 1754

WarningBecause they are prefixes, neither ^ nor ~ can appear as ordinary field data. The text and fonts guide shows the hexadecimal escape that gets around this.p. 190

Start, end and what sits between

Question What are the parts of a label format?

A valid format starts with ^XA and ends with ^XZ. When ^XZ is received, the label prints.pp. 370, 375

As a curiosity, the guide says ^XA can be replaced by the single control character STX (hexadecimal 02), ^XZ by ETX (03) and ^FS by SI (0F). You will almost never write these by hand.pp. 204, 370, 375

Between those two brackets you place fields. A field is a position, optionally a font, the data, and a separator that closes it.

Fields: position, data, separator

Question Do I need ^FS after every line?

^FO sets where a field starts. Its x and y values are dots, counted from the label home, and they fix the field's upper-left corner.p. 201

The default label home is the upper-left corner of the label, position 0,0. The coordinates guide covers coordinates and dots.p. 293

^FD carries the data to print. It accepts any printable character except the two prefix characters, up to 3072 bytes.p. 190

^FS ends the field definition.p. 204

On whether every line needs one, the guide says two things. The command entry recommends an ^FS after every command that creates a printable line. The scripting-shortcuts section says ^FS is only needed to separate specific fields, shows the same label without the extras, and notes that ^XZ closes the last field.pp. 204, 1765, 1766

TipOur advice: close every field with ^FS. It costs three bytes, and it keeps each field self-contained when you later reorder or generate them.

Build one small label, three steps

Question How do I place text, a line and a barcode on one label?

Step one is a line of text. ^A picks the font, orientation and size: font 0 is the scalable font, N means normal orientation, and the two numbers are height and width in dots, each from 10 to 32000 for a scalable font. If you would rather not repeat ^A on every field, ^CF sets the font and size used by every field that has no ^A of its own.pp. 50, 60, 154

Step two adds a rule under it with ^GB, the graphic box command. Its first three values are width, height and border thickness in dots; a width or height may not be smaller than the thickness, so 300,3,3 is a thin line.p. 210

Step three adds a Code 128 barcode. ^BY sets defaults for later barcodes: module width, wide-to-narrow ratio and height. The module width is 2 dots at power-up and a ^BY stays in effect until the next one. ^BC then prints the code: N is normal orientation, 80 is the height in dots, and Y turns on the human-readable line.pp. 94, 148, 149

The linear barcodes and 2D codes guides go through barcodes properly.

example.zplZPL
^XA
^FO40,30^A0N,40,40^FDBin A17^FS
^XZ

Step one: one text field, 40 dots from the left and 30 down, in the scalable font at 40 by 40 dots.

example.zplZPL
^XA
^FO40,30^A0N,40,40^FDBin A17^FS
^FO40,85^GB300,3,3^FS
^XZ

Step two: a second field draws a line 300 dots long and 3 dots thick below the text.

example.zplZPL
^XA
^FX Shelf label^FS
^FO40,30^A0N,40,40^FDBin A17^FS
^FO40,85^GB300,3,3^FS
^FO40,110^BY2^BCN,80,Y,N,N^FDA170042^FS
^XZ

Step three: the finished label, with a comment on the second line and a Code 128 barcode below the rule, 80 dots high with its text line on.

Leaving a comment

Question How do I leave a comment in my ZPL?

^FX starts a comment. Everything after it, up to the next caret or tilde, has no effect on the label, so keep both characters out of a comment; the guide advises avoiding them. The guide says to follow the comment with ^FS.p. 209

Before you send the first label

Question How do I find my printer's resolution and firmware?

Print a configuration label first. It shows the firmware version, and the guide's starter checklist uses it to confirm the left position and label top are both 000 and to read the printer's resolution.pp. 47, 49

TipSkip the guide's advice about DOS editors and copying files from a DOS command line; it is dated. Any editor that saves plain text works, and how the text reaches the printer depends on your connection.p. 49

The same label with BarcoderX

Question Where does BarcoderX fit in?

BarcoderX is pre-launch and its API is not final. It is designed to let you describe a label once in .NET and emit ZPL or EPL. The Developers page shows how the SDK is layered.

Questions

Can I put SGD commands in the same file as a ZPL label?

Keep them apart. The guide says ZPL and SGD commands should be sent as separate files, and for G-Series printers it says EPL, ZPL and SGD must each go in their own file.p. 47

What does the printer need to print a label?

A format that starts with ^XA and ends with ^XZ. The label prints when ^XZ is received.pp. 370, 375

How do I add a comment that does not print?

Use ^FX followed by your text, without a caret or tilde inside it, and close it with ^FS.p. 209

Commands in this guide

BarcoderX is a .NET SDK for thermal labels and barcodes. See how it prints and exports labels.

Source Zebra, ZPL II, ZBI 2, Set-Get-Do, Mirror, WML Programming Guide, P1134473-11EN Rev A, 2026/07/05, pages 47 to 50, 60, 94, 148, 149, 152, 154, 166, 190, 201, 204, 209, 210, 293, 311, 370, 375, 1754, 1765, 1766.

Written by BarcoderX in its own words. Checked against the guide on 2026-11-14.

ZPL and ZPL II are trademarks of Zebra Technologies Corporation. This reference is written by BarcoderX in its own words from Zebra's published programming guide. BarcoderX is an independent product and is not affiliated with, endorsed by or sponsored by Zebra Technologies.