Skip to main content

ZPL how-to

EAN-13 and Code 93 barcodes in ZPL

Both barcodes print from one command, but both change some data without telling you: EAN-13 replaces your check digit, and Code 93 takes only capitals, digits and a few symbols as typed.

EAN-13: ^BE

zpl
^XA
^BY2^FO40,40^BEN,100,Y,N^FD590123412345^FS
^XZ
  • ^BEN,100,Y,N: normal orientation, 100 dots tall, the digits printed under the bars, not above. ^BY2 makes the narrowest bar 2 dots wide, 0.25 mm at 203 dpi. That is under the 0.264 mm GS1 gives as EAN-13's smallest; ^BY3, 0.375 mm, is over it. The samples on this page keep ^BY2; change it to ^BY3 for a code that meets GS1's width.
  • 100 dots is 12.5 mm at 203 dpi. For retail scanning, GS1's bar height grows with bar width: 22.85 mm at 0.330 mm. At ^BY3 that is about 26 mm, 208 dots: ^BY3,2,59 and ^BEN,208,Y,N. With its digits it is 235 dots tall, so it needs a 4x2 label, at a y up to 171. It does not fit a 3x1 label.
  • Send 12 digits. The printer works out the 13th, the check digit, itself: this label scanned as 5901234123457.

What EAN-13 does to your data

  • A 13th digit is replaced. Zebra's reference says ^BE takes exactly 12 digits. Sent as 5901234123450, with a wrong check digit, the label scanned as 5901234123457: the printer's check digit, not yours, and no error. If your numbers carry their own check digit, check it before printing, or a wrong one goes unnoticed.
  • Fewer digits are padded. Eleven digits get a 0 in front: the label for 90123412345 scanned as 0901234123452.
  • The first digit prints left of ^FO. In Labelary the code at ^FO40 started 21 dots further left, at x 19, with the first digit in front of the bars. At ^FO0 that digit and the margin a scanner needs were off the label, and the code did not scan. The digit starts 21 dots left of x at ^BY2 and 34 at ^BY3, so an x of 40 keeps it on the label either way.
  • Leave room on the right too. At ^BY3 the bars are 285 dots wide, and a scanner needs 21 dots of blank label after them. On a 3x1 label, 609 dots wide, the code scanned at ^FO310 but not at ^FO320. Keep x at most 303 on a 3x1 label, 506 on 4x2. With its digits the code is 127 dots tall, so keep y at most 76 on a 3x1 label, 279 on 4x2.

Code 93: ^BA

zpl
^XA
^BY2^FO40,40^BAN,100,Y,N,N^FDPART-42^FS
^XZ
  • ^BAN,100,Y,N,N: normal, 100 dots tall, text under the bars, and no check digit printed in that text. It scanned as PART-42.
  • Capital letters, digits, space and - . $ / + % scan as sent. In Labelary, AZ09-. $/+% scanned exactly.

Characters Code 93 changes

  • Lower case becomes upper case. In Labelary, part-42 scanned as PART-42.
  • &, ', ( and ) are not themselves. Zebra's reference uses these four as stand-ins for Code 93's four shift characters, and each one joins with the character after it to make a single character. O'BRIEN scanned as O, a control character, then RIEN: the apostrophe and the B became one character. BIN(2) scanned as BIN2. The text under the bars was garbled too.

Every other character: pairs

Code 93 can hold all 128 ASCII characters, written as pairs: a shift stand-in, then a capital letter. Zebra's reference has the full table. The ones you are most likely to need:

  • ) before a capital makes it lower case: P)A)R)T-42 scanned as Part-42.
  • (F is &, (G is ', (H and (I are ( and ). O(GBRIEN scanned as O'BRIEN, and BIN(H2(I as BIN(2).
  • Each pair is two characters of barcode, so the code gets wider: in Labelary, Part-42 written in pairs was 254 dots wide, against 200 for PART-42.
  • Code 128 is simpler when your scanner accepts it: it takes lower case and punctuation as typed, and scanned A&B(2) exactly. Code 128 barcodes in ZPL covers its width and height.

The same barcodes with zeepler

Send this body to POST https://api.zeepler.com/v1/zeeplify with your API key in the x-api-key header. It is a working request, not an illustration: on every change, our tests run this same file through the API's code and compare the result with the ZPL below.

json
1{
2 "config": {
3 "size": "4x2"
4 },
5 "data": {
6 "ean": "590123412345",
7 "part": "PART-42"
8 },
9 "templates": [
10 {
11 "type": "BarCode",
12 "dataPath": "ean",
13 "coords": [40, 40],
14 "style": "ean13"
15 },
16 {
17 "type": "BarCode",
18 "dataPath": "part",
19 "coords": [40, 220],
20 "style": "code93"
21 }
22 ]
23}

And the ZPL that comes back, ready to send to the printer:

zpl
^XA^MCY^XZ
    ^XA
    ^SZ2
    ^MMT
    ^MNY
    ^LL406
    ^PW812
    ^LH0,0
^BY3,2,59^FO40,40^BEN,100,Y,N^FD590123412345^FS
^BY2,2,59^FO40,220^BAN,100,Y,N,N^FDPART-42^FS
^XZ

Set a BarCode element's style to "ean13" or "code93". zeepler emits the same commands as above, 100 dots tall unless you set height, with the text under the bars: EAN-13 after ^BY3,2,59, so its bar width meets GS1's minimum, and Code 93 after ^BY2,2,59. Both scanned as they should.

What zeepler checks, and what it does not yet:

  • An ean13 value must be 12 or 13 digits, or the request is refused with a 400. A 13th digit is not checked: a wrong one is replaced by the printer, as above, so check it yourself.
  • A code93 value is not checked either, but zeepler writes lower case and punctuation as the pairs above, so the barcode scans as your data: it sends O'BRIEN as O(GBRIEN. If you write the pairs yourself, set "fullAscii": false and zeepler sends the value unchanged.
  • coords is checked only to fall inside the label. Give an EAN-13 an x from 40 to 303 and a y up to 76 on a 3x1 label, or an x to 506 and a y to 279 on 4x2, so its first digit, the blank space after its bars and its digits all fit. Those y limits are for the default height.
  • The bars are 100 dots (12.5 mm) tall by default, shorter than GS1 asks for retail scanning. For a retail code set "height": 208: zeepler then sends ^BEN,208,Y,N, 235 dots tall with its digits, so it needs a 4x2 label, at a y up to 171. It does not fit a 3x1 label: zeepler refuses an EAN-13 height over the label's less its 27 dots of digits, 176 on 3x1 and 379 on 4x2.

Sending it

  • Call the API from your own server or integration engine, not from a web page. An API key in a browser is a key anyone can copy.
  • A successful call answers 200 with the ZPL as plain text. A request the API cannot turn into a label answers 400 with every problem listed by field, and is not billed.
  • Send the ZPL to a Zebra or other ZPL printer at 203 dpi. At 300 dpi the same label prints at two-thirds of the size.

The API reference has every field and status code.

Before you go live

  • Text does not wrap. A value longer than the space you left runs off the edge of the label, so set maxLength on any field whose length you do not control.
  • Coordinates are in dots from the top-left corner. Print one label, measure it, and adjust: there is no preview.
  • Scan every barcode and QR code on a printed label before relying on it.

Related guides

Help with an integration

Email info@zeepler.com. You will get a reply within 2 business days. The support policy covers response times and version changes.