Skip to content
DockLabel

ZPL GS1-128 example, annotated line by line

A complete ZPL label with a GS1-128 SSCC barcode that you can copy, followed by an explanation of every line. The code on this page is generated by the same library as the label generator, so it cannot drift from what the tool produces.

The complete example (203 dpi)

A 4 x 6 inch GS1 logistic label for SSCC 006141410000000012. The addresses are invented.

^XA
^CI28
^PW812
^LL1218
^LH0,0
^FO30,24^A0N,25,20^FDFROM^FS
^FO152,24^A0N,25,20^FDNorthwind Supply Co^FS
^FO152,55^A0N,25,20^FD1200 Industrial Pkwy^FS
^FO152,85^A0N,25,20^FDReno, NV 89502^FS
^FO30,154^GB751,3,3^FS
^FO30,175^A0N,25,20^FDTO^FS
^FO152,175^A0N,39,22^FDContoso Retail DC 14^FS
^FO152,221^A0N,39,22^FD8800 Distribution Way^FS
^FO152,268^A0N,39,22^FDDenver, CO 80202^FS
^FO30,365^GB751,3,3^FS
^FO30,382^A0N,25,20^FDCARRIER^FS
^FO30,416^A0N,37,23^FDExample Freight^FS
^FO558,382^A0N,25,20^FDCARTON^FS
^FO558,416^A0N,37,17^FD1 OF 12^FS
^FO30,479^A0N,25,20^FDPO NUMBER^FS
^FO30,514^A0N,37,26^FDPO-4471902^FS
^FO30,577^GB751,3,3^FS
^FO30,589^A0N,25,20^FDSSCC^FS
^FO30,625^A0N,61,41^FD006141410000000012^FS
^FO30,698^GB751,3,3^FS
^FO94,735^BY4^BCN,305,N,N,N,N^FD>;>800006141410000000012^FS
^FO95,1056^A0N,32,28^FD(00) 006141410000000012^FS
^XZ
The label this ZPL printsFROMNorthwind Supply Co1200 Industrial PkwyReno, NV 89502TOContoso Retail DC 148800 Distribution WayDenver, CO 80202CARRIERExample FreightCARTON1 OF 12PO NUMBERPO-4471902SSCC006141410000000012(00) 006141410000000012
What the example prints.

The barcode line, piece by piece

Everything specific to GS1-128 is in one line. The pieces, as documented in Zebra's ZPL II guide for ^BC:

  • ^BY4 sets the module width, the width of the narrowest bar, to 4 dots.
  • ^BCN,h,N,N,N,N draws Code 128: normal orientation, h dots tall, no interpretation line from the printer, no UCC check digit added by the printer, and mode N, meaning no automatic mode. With mode N the printer encodes exactly what the field data says.
  • >; at the start of the field data selects subset C, where each pair of digits becomes one barcode character.
  • >8 is FNC1. Directly after the start code it is what makes this a GS1-128 barcode rather than plain Code 128.
  • 00 is the application identifier for an SSCC, and the 18 digits after it are the SSCC including its check digit. No parentheses: those are for people.

The parentheses appear in the next line instead, a plain text field reading (00) 006141410000000012. Zebra's guide describes this approach: turn the interpretation line off and write a separate text field so the text can show parentheses. The check digit in that text has to be correct, because the printer is not calculating it. The generator calculates it, and you can confirm any number with the check digit calculator.

Invocation codes used in GS1-128 field data

Inside ^BC field data, a > followed by one character is a control code, not data. These are the ones a GS1-128 barcode needs, from the invocation table in Zebra's guide:

CodeMeaning
>;Start in subset C (pairs of digits)
>:Start in subset B (letters, digits, punctuation)
>8FNC1. Right after the start it makes the symbol GS1-128. Later on it is the separator.
>6Switch from subset C to subset B
>5Switch from subset B to subset C
>0A literal > character in subset B

One trap is worth knowing. Zebra's guide says that in subset C an extra unpaired digit just before a code shift is ignored. So an odd number of digits cannot simply be left in subset C: the last digit has to be moved into subset B with >6 first. The encoder on this site always does that.

More field data examples

The same encoder, given other element strings:

Printed text^FD field dataWhat to notice
(10)2503X>;>8102503>6XDigits in subset C, then a switch to B for the letter.
(37)24(400)PO-7781>;>83724>840>60PO->57781A separator after the count, because (37) has no predefined length.
(01)09521234500001(10)ABC123>;>8010952123450000110>6ABC123No separator after the GTIN. Its length is predefined.

Which element strings need the >8 separator is covered in the application identifier table.

Every line explained

ZPLWhat it does
^XAStart of the label format.
^CI28Text is UTF-8.
^PW812Print width: 4 inches at 203 dpi.
^LL1218Label length: 6 inches at 203 dpi.
^LH0,0Label home at the top left corner.
^FO30,24^A0N,25,20^FDFROM^FSData title "FROM".
^FO152,24^A0N,25,20^FDNorthwind Supply Co^FSAddress line.
^FO152,55^A0N,25,20^FD1200 Industrial Pkwy^FSAddress line.
^FO152,85^A0N,25,20^FDReno, NV 89502^FSAddress line.
^FO30,154^GB751,3,3^FSRule between label zones, drawn as a filled box.
^FO30,175^A0N,25,20^FDTO^FSData title "TO".
^FO152,175^A0N,39,22^FDContoso Retail DC 14^FSAddress line.
^FO152,221^A0N,39,22^FD8800 Distribution Way^FSAddress line.
^FO152,268^A0N,39,22^FDDenver, CO 80202^FSAddress line.
^FO30,365^GB751,3,3^FSRule between label zones, drawn as a filled box.
^FO30,382^A0N,25,20^FDCARRIER^FSData title "CARRIER".
^FO30,416^A0N,37,23^FDExample Freight^FSField value.
^FO558,382^A0N,25,20^FDCARTON^FSData title "CARTON".
^FO558,416^A0N,37,17^FD1 OF 12^FSField value.
^FO30,479^A0N,25,20^FDPO NUMBER^FSData title "PO NUMBER".
^FO30,514^A0N,37,26^FDPO-4471902^FSField value.
^FO30,577^GB751,3,3^FSRule between label zones, drawn as a filled box.
^FO30,589^A0N,25,20^FDSSCC^FSData title "SSCC".
^FO30,625^A0N,61,41^FD006141410000000012^FSThe SSCC as large text, for people reading the label.
^FO30,698^GB751,3,3^FSRule between label zones, drawn as a filled box.
^FO94,735^BY4^BCN,305,N,N,N,N^FD>;>800006141410000000012^FSGS1-128 barcode. ^BY4 sets the module width to 4 dots. ^BCN draws Code 128 305 dots tall with the printer's own interpretation line off and no automatic mode. In the data, >; starts subset C, >8 is FNC1 (which makes it GS1-128), then the AI and its digits.
^FO95,1056^A0N,32,28^FD(00) 006141410000000012^FSHuman readable interpretation of the barcode, with the AI in parentheses. Printed as its own text field because the printer's interpretation line omits the parentheses.
^XZEnd of the label format. The printer prints it.

What changes at 300 dpi

ZPL positions are in printer dots, so the same label on a 300 dpi printer needs different numbers throughout: ^PW and ^LL become 1200 and 1800, and every ^FO coordinate and font size is larger. The barcode is not scaled by multiplying. A module must be a whole number of dots, so it goes from 4 dots to 6, which keeps it inside the 0.495 to 0.940 mm range the GS1 General Specifications set for logistic units (table 5-51). The barcode line at 300 dpi:

^FO132,1086^BY6^BCN,450,N,N,N,N^FD>;>800006141410000000012^FS

The field data is identical. Only the position, module width and height change. The size rules are explained on the GS1-128 label page.

Text safety

^ and ~ start commands in ZPL, so an address containing either would break the label. When a text field contains one, the generator writes the field with ^FH_ and replaces the character with a hex escape, _5E or _7E. Text without those characters is written as it is.

This example is for reading and adapting. To get the same label with your own shipment data, use the generator. For the label's layout rules see the pallet label template and the SSCC label guide.

Make this label now: fill in the shipment, preview it, and copy or download the ZPL.

Open the label generator

Sources