---
source: https://carbone.io/examples/ucc-128-carton-label-zpl/
title: "UCC-128 Labels in ZPL: GS1-128 SSCC Carton Labels | Carbone"
description: "Generate UCC-128 carton labels in ZPL with the Carbone API: a TXT template prints the GS1-128 ship-to ZIP and SSCC barcodes that retail routing guides require."
generated_at: "2026-11-17"
---

# UCC-128 carton label

Cartons from your WMS, as ZPL for Zebra printers

[![UCC-128 carton label: TXT generated from a TXT template and JSON data](/examples/ucc-128-carton-label-zpl/thumb-result.webp)](/examples/ucc-128-carton-label-zpl/result.txt "Download the generated document")

[Download template](/examples/ucc-128-carton-label-zpl/template.txt)

[Sample data](/examples/ucc-128-carton-label-zpl/data.json)

[Download the generated ZPL](/examples/ucc-128-carton-label-zpl/result.txt)

- **Template:** TXT
- **Export as:** TXT, PDF, DOCX, ODT, HTML
- **Carbone:** 5.0+

Features

-   [Loop](/documentation/design/repetitions/with-arrays.md)
-   [Nested array](/documentation/design/repetitions/with-arrays.md)
-   [Condition](/documentation/design/conditions/overview.md)
-   [Alias](/documentation/design/substitutions/aliases.md)
-   [Aggregation](/documentation/design/computation/aggregation.md)
-   [Text](/documentation/design/formatters/text.md)

## Generate UCC-128 carton labels from your software

Retailers ask their suppliers for a UCC-128 label on every carton, now called the GS1-128 label: the zones of the North American common label, built on the [GS1 Logistic Label Guideline](https://www.gs1.org/standards/gs1-logistic-label-guideline/current-standard), with the details set in each routing guide. The distribution center scans the SSCC barcode of the carton and finds it in the advance ship notice of the shipment. Your WMS or ERP sends the shipment to the Carbone API as JSON and gets back ZPL for a 4x6 Zebra desktop printer, one label per carton. In this example, Fabrikam Outdoor Supply labels the 2 cartons it announces in the [EDI 856 example](/examples/edi-856-advance-ship-notice/index.md): same distribution center, mark-for store, carrier, bill of lading, PO, SSCCs and contents.

## UCC-128 label zones

The label reads from top to bottom, from the addresses to the SSCC:

| Zone | Name | On this label |
| --- | --- | --- |
| A | Ship from | Name and address of the supplier |
| B | Ship to | Name and address of the distribution center, with its number |
| C | Ship-to postal code | The ZIP code as a GS1-128 barcode `(420)`, for the carrier's sorting |
| D | Carrier | SCAC code of the carrier, PRO number, bill of lading, `CARTON 1 OF 2` |
| E and F | Order | PO number, department and contents: the UPC and quantity of a carton with one product, or `MIXED` |
| G | Store | The mark-for store as a GS1-128 barcode `(91)`, for sorting at the distribution center |
| H | Mark for | The store number in large type and the store name. Without a mark-for store, zones G and H show the DC number |
| I | SSCC | The serial number of the carton as a GS1-128 barcode `(00)`, always at the bottom |

The rows follow the North American layout: about 1 inch high for zones A to H, 2 inches for the SSCC. The three barcodes have 0.5 mm narrow bars and a quiet zone of 10 narrow bars on each side. The SSCC barcode keeps the full GS1 height, 36 mm, and the `(420)` and `(91)` barcodes fit their 1-inch zones at 20 mm. For a pallet label with the product, the count, the batch and the date in barcodes, see the [GS1 pallet label example](/examples/gs1-pallet-label-zpl/index.md).

## UCC-128 carton label example

### Template

```text
{#zpl($text) = $text:replace('_', '_5F'):replace('^', '_5E'):replace('~', '_7E')}{d.cartons[i]}^XA
^CI28
^PW812^LL1218
^FO48,20^A0N,20,20^FDSHIP FROM^FS
^FO48,46^A0N,26,26^FH^FD{$zpl(d.shipFrom.name)}^FS
^FO48,80^A0N,24,24^FH^FD{$zpl(d.shipFrom.street)}^FS
^FO48,110^A0N,24,24^FH^FD{$zpl(d.shipFrom.city)}, {d.shipFrom.state} {d.shipFrom.zip}^FS
^FO366,0^GB3,176,3^FS
^FO392,20^A0N,20,20^FDSHIP TO^FS
^FO392,46^A0N,36,36^FH^FD{$zpl(d.shipTo.name)}^FS
^FO392,90^A0N,30,30^FH^FD{$zpl(d.shipTo.street)}^FS
^FO392,126^A0N,30,30^FH^FD{$zpl(d.shipTo.city)}, {d.shipTo.state} {d.shipTo.zip}^FS
^FO0,176^GB812,3,3^FS
^FO48,190^A0N,20,20^FDSHIP TO POSTAL CODE^FS
^FO48,216^BY4^BCN,160,N,N,N,D^FD(420){d.shipTo.zip}^FS
^FO48,384^A0N,34,34^FD(420) {d.shipTo.zip}^FS
^FO548,176^GB3,256,3^FS
^FO568,190^A0N,20,20^FDCARRIER (SCAC)^FS
^FO568,212^A0N,28,28^FD{d.shipment.carrierScac}^FS
^FO568,250^A0N,20,20^FDPRO^FS
^FO568,272^A0N,28,28^FD{d.shipment.proNumber}^FS
^FO568,310^A0N,20,20^FDB/L^FS
^FO568,332^A0N,26,26^FD{d.shipment.billOfLading}^FS
^FO568,370^A0N,20,20^FDCARTON^FS
^FO568,392^A0N,34,34^FD{d.cartons[i].sscc:cumCount} OF {d.cartons:len}^FS
^FO0,432^GB812,3,3^FS
^FO48,448^A0N,20,20^FDPO^FS
^FO48,472^A0N,44,44^FD{d.order.poNumber}^FS
^FO330,448^A0N,20,20^FDDEPT^FS
^FO330,472^A0N,44,44^FD{d.order.department}^FS
^FO568,448^A0N,20,20^FDCONTENTS^FS
{d.cartons[i].items:len:ifEQ(1):showBegin}^FO568,472^A0N,28,28^FDUPC {d.cartons[i].items[0].upc}^FS
^FO568,504^A0N,28,28^FDQTY {d.cartons[i].items[0].qty}^FS
{d.cartons[i].items:len:showEnd}{d.cartons[i].items:len:ifGT(1):showBegin}^FO568,472^A0N,44,44^FDMIXED^FS
{d.cartons[i].items:len:showEnd}^FO0,546^GB812,3,3^FS
{d.order.markFor.storeNumber:ifNEM:showBegin}^FO48,562^A0N,20,20^FDSTORE^FS
^FO48,588^BY4^BCN,160,N,N,N,D^FH^FD(91){$zpl(d.order.markFor.storeNumber)}^FS
^FO48,756^A0N,34,34^FH^FD(91) {$zpl(d.order.markFor.storeNumber)}^FS
^FO548,546^GB3,258,3^FS
^FO568,562^A0N,20,20^FDMARK FOR^FS
^FO568,588^A0N,90,90^FH^FD{$zpl(d.order.markFor.storeNumber)}^FS
^FO568,690^FB224,2,0,L^A0N,24,24^FH^FD{$zpl(d.order.markFor.name)}^FS
{d.order.markFor.storeNumber:showEnd}{d.order.markFor.storeNumber:ifEM:showBegin}^FO48,562^A0N,20,20^FDDISTRIBUTION CENTER^FS
^FO48,588^A0N,100,100^FDDC {d.shipTo.dcNumber}^FS
{d.order.markFor.storeNumber:showEnd}^FO0,804^GB812,3,3^FS
^FO48,820^A0N,20,20^FDSSCC^FS
^FO48,848^BY4^BCN,290,N,N,N,D^FD(00){d.cartons[i].sscc}^FS
^FO48,1148^A0N,36,36^FD(00) {d.cartons[i].sscc:substr(0, 1)} {d.cartons[i].sscc:substr(1, 8)} {d.cartons[i].sscc:substr(8, 17)} {d.cartons[i].sscc:substr(17)}^FS
^XZ
{d.cartons[i+1]}
```

### JSON data

```json
{
  "shipment": { "carrierScac": "NWFX", "proNumber": "7310442586", "billOfLading": "08627140010441701" },
  "shipTo": { "name": "Contoso Retail DC 6094", "dcNumber": "6094", "street": "1200 Distribution Blvd", "city": "Columbus", "state": "OH", "zip": "43217" },
  "shipFrom": { "name": "Fabrikam Outdoor Supply", "street": "4800 Cascade Commerce Way", "city": "Reno", "state": "NV", "zip": "89523" },
  "order": { "poNumber": "4500217784", "department": "23", "markFor": { "name": "Contoso Retail Easton", "storeNumber": "1187" } },
  "cartons": [
    { "sscc": "008627140000045018", "items": [ { "upc": "862714001014", "qty": 4 }, { "upc": "862714002059", "qty": 6 } ] },
    { "sscc": "008627140000045025", "items": [ { "upc": "862714003124", "qty": 12 } ] }
  ]
}
```

### Generated ZPL labels

```text
^XA
^CI28
^PW812^LL1218
^FO48,20^A0N,20,20^FDSHIP FROM^FS
^FO48,46^A0N,26,26^FH^FDFabrikam Outdoor Supply^FS
^FO48,80^A0N,24,24^FH^FD4800 Cascade Commerce Way^FS
^FO48,110^A0N,24,24^FH^FDReno, NV 89523^FS
^FO366,0^GB3,176,3^FS
^FO392,20^A0N,20,20^FDSHIP TO^FS
^FO392,46^A0N,36,36^FH^FDContoso Retail DC 6094^FS
^FO392,90^A0N,30,30^FH^FD1200 Distribution Blvd^FS
^FO392,126^A0N,30,30^FH^FDColumbus, OH 43217^FS
^FO0,176^GB812,3,3^FS
^FO48,190^A0N,20,20^FDSHIP TO POSTAL CODE^FS
^FO48,216^BY4^BCN,160,N,N,N,D^FD(420)43217^FS
^FO48,384^A0N,34,34^FD(420) 43217^FS
^FO548,176^GB3,256,3^FS
^FO568,190^A0N,20,20^FDCARRIER (SCAC)^FS
^FO568,212^A0N,28,28^FDNWFX^FS
^FO568,250^A0N,20,20^FDPRO^FS
^FO568,272^A0N,28,28^FD7310442586^FS
^FO568,310^A0N,20,20^FDB/L^FS
^FO568,332^A0N,26,26^FD08627140010441701^FS
^FO568,370^A0N,20,20^FDCARTON^FS
^FO568,392^A0N,34,34^FD1 OF 2^FS
^FO0,432^GB812,3,3^FS
^FO48,448^A0N,20,20^FDPO^FS
^FO48,472^A0N,44,44^FD4500217784^FS
^FO330,448^A0N,20,20^FDDEPT^FS
^FO330,472^A0N,44,44^FD23^FS
^FO568,448^A0N,20,20^FDCONTENTS^FS
^FO568,472^A0N,44,44^FDMIXED^FS
^FO0,546^GB812,3,3^FS
^FO48,562^A0N,20,20^FDSTORE^FS
^FO48,588^BY4^BCN,160,N,N,N,D^FH^FD(91)1187^FS
^FO48,756^A0N,34,34^FH^FD(91) 1187^FS
^FO548,546^GB3,258,3^FS
^FO568,562^A0N,20,20^FDMARK FOR^FS
^FO568,588^A0N,90,90^FH^FD1187^FS
^FO568,690^FB224,2,0,L^A0N,24,24^FH^FDContoso Retail Easton^FS
^FO0,804^GB812,3,3^FS
^FO48,820^A0N,20,20^FDSSCC^FS
^FO48,848^BY4^BCN,290,N,N,N,D^FD(00)008627140000045018^FS
^FO48,1148^A0N,36,36^FD(00) 0 0862714 000004501 8^FS
^XZ
^XA
^CI28
^PW812^LL1218
^FO48,20^A0N,20,20^FDSHIP FROM^FS
^FO48,46^A0N,26,26^FH^FDFabrikam Outdoor Supply^FS
^FO48,80^A0N,24,24^FH^FD4800 Cascade Commerce Way^FS
^FO48,110^A0N,24,24^FH^FDReno, NV 89523^FS
^FO366,0^GB3,176,3^FS
^FO392,20^A0N,20,20^FDSHIP TO^FS
^FO392,46^A0N,36,36^FH^FDContoso Retail DC 6094^FS
^FO392,90^A0N,30,30^FH^FD1200 Distribution Blvd^FS
^FO392,126^A0N,30,30^FH^FDColumbus, OH 43217^FS
^FO0,176^GB812,3,3^FS
^FO48,190^A0N,20,20^FDSHIP TO POSTAL CODE^FS
^FO48,216^BY4^BCN,160,N,N,N,D^FD(420)43217^FS
^FO48,384^A0N,34,34^FD(420) 43217^FS
^FO548,176^GB3,256,3^FS
^FO568,190^A0N,20,20^FDCARRIER (SCAC)^FS
^FO568,212^A0N,28,28^FDNWFX^FS
^FO568,250^A0N,20,20^FDPRO^FS
^FO568,272^A0N,28,28^FD7310442586^FS
^FO568,310^A0N,20,20^FDB/L^FS
^FO568,332^A0N,26,26^FD08627140010441701^FS
^FO568,370^A0N,20,20^FDCARTON^FS
^FO568,392^A0N,34,34^FD2 OF 2^FS
^FO0,432^GB812,3,3^FS
^FO48,448^A0N,20,20^FDPO^FS
^FO48,472^A0N,44,44^FD4500217784^FS
^FO330,448^A0N,20,20^FDDEPT^FS
^FO330,472^A0N,44,44^FD23^FS
^FO568,448^A0N,20,20^FDCONTENTS^FS
^FO568,472^A0N,28,28^FDUPC 862714003124^FS
^FO568,504^A0N,28,28^FDQTY 12^FS
^FO0,546^GB812,3,3^FS
^FO48,562^A0N,20,20^FDSTORE^FS
^FO48,588^BY4^BCN,160,N,N,N,D^FH^FD(91)1187^FS
^FO48,756^A0N,34,34^FH^FD(91) 1187^FS
^FO548,546^GB3,258,3^FS
^FO568,562^A0N,20,20^FDMARK FOR^FS
^FO568,588^A0N,90,90^FH^FD1187^FS
^FO568,690^FB224,2,0,L^A0N,24,24^FH^FDContoso Retail Easton^FS
^FO0,804^GB812,3,3^FS
^FO48,820^A0N,20,20^FDSSCC^FS
^FO48,848^BY4^BCN,290,N,N,N,D^FD(00)008627140000045025^FS
^FO48,1148^A0N,36,36^FD(00) 0 0862714 000004502 5^FS
^XZ
```

## How to create a UCC-128 carton label

### 1\. Print one label per carton

The label is a [loop](/documentation/design/template-formats/txt.md#loops) on `d.cartons`: `{d.cartons[i]}` before `^XA` and `{d.cartons[i+1]}` after `^XZ` repeat the whole label for each carton. `^PW812^LL1218` sets a 4x6 label at 203 dpi. `{d.cartons[i].sscc:cumCount} OF {d.cartons:len}` prints `1 OF 2` in zone D.

### 2\. Write the GS1-128 barcodes

```text
^FO48,848^BY4^BCN,290,N,N,N,D^FD(00){d.cartons[i].sscc}^FS
```

-   `^BY4` sets narrow bars of 4 dots, 0.5 mm at 203 dpi, and `^BCN,290` a Code 128 of 290 dots, 36 mm.
-   Mode `D` (UCC/EAN) starts the barcode with FNC1, the character that makes it a GS1-128, and removes the parentheses: scanners read `]C1` then `00008627140000045018`. Zones C and G work the same way: `(420){d.shipTo.zip}` reads `42043217`, and `(91)` with the store number reads `911187`.
-   The `N` after the height hides the interpretation line of the printer. The next field prints the SSCC in groups with `:substr`: `(00) 0 0862714 000004501 8` is the extension digit, the GS1 company prefix, the serial number and the check digit. `:substr(1, 8)` fits a 7-digit company prefix: change the positions for yours.

Send the SSCC with its check digit, as your WMS allocates it, and the same SSCC in the `MAN` segment of the 856.

### 3\. Print the contents and the final destination

Carbone decides both from the data, with [conditional blocks](/documentation/design/conditions/conditional-blocks.md#showbegin-showend):

-   **Contents:** `{d.cartons[i].items:len:ifEQ(1):showBegin}` keeps the UPC and quantity of the only product, `{d.cartons[i].items[0].upc}` and `{d.cartons[i].items[0].qty}`, and `{d.cartons[i].items:len:ifGT(1):showBegin}` prints `MIXED` when the carton holds several products. The first carton holds 2 products, so its label prints `MIXED`. The second holds 12 units of UPC 862714003124, as in the `LIN` and `SN1` segments of the 856.
-   **Mark for:** `{d.order.markFor.storeNumber:ifNEM:showBegin}` keeps zones G and H when the order has a mark-for store, and `{d.order.markFor.storeNumber:ifEM:showBegin}` prints the DC number instead. The order goes to store 1187 through the distribution center, as in the `N1*Z7` segment of the 856, so both labels print `(91) 1187`.

### 4\. Escape the ZPL characters

`^` and `~` start ZPL commands, so a name that contains them breaks the label. The alias on the first line encodes them in hexadecimal, and `^FH` before `^FD` tells the printer to decode them:

```text
{#zpl($text) = $text:replace('_', '_5F'):replace('^', '_5E'):replace('~', '_7E')}
```

`_` is replaced first, so the codes of the next replacements are not encoded twice. `{$zpl(d.shipTo.name)}` applies it to the names, the addresses and the store number. `^CI28` sets UTF-8, the encoding of Carbone reports, so accented names print correctly. See the [ZPL labels section of the TXT templates page](/documentation/design/template-formats/txt.md#zpl-labels) and [parametrized aliases](/documentation/design/substitutions/aliases.md#parametrized-alias).

## Related Examples

- [EDI 856 ship notice](/examples/edi-856-advance-ship-notice/index.md): TXT template to EDI.
- [GS1 pallet label](/examples/gs1-pallet-label-zpl/index.md): TXT template to ZPL.
- [SSCC carton label](/examples/label-barcode/index.md): DOCX template to PDF.

## Related topics

- [CMR consignment note](/examples/cmr-consignment-note/index.md)
- [EDI 856 ship notice](/examples/edi-856-advance-ship-notice/index.md)
- [GS1 pallet label](/examples/gs1-pallet-label-zpl/index.md)
- [SSCC carton label](/examples/label-barcode/index.md)
- [Inventory count sheets](/examples/stock-inventory-spreadsheet/index.md)
- [Warehouse floor plan heat map](/examples/warehouse-floor-plan-heatmap/index.md)
