ZPL how-to
Convert EPL to ZPL
There is no general converter from EPL to ZPL: Zebra's EPL and ZPL programming guides describe none, and the accepted answer on Stack Overflow rebuilds the label in a design tool instead. Translate it by hand. Most EPL2 commands have a ZPL command that does the same job, and both languages measure in dots from the top-left corner.
Where this comes from
Each command below is from Zebra's EPL Programming Guide (14245L-003 Rev. A, 2013) and ZPL Programming Guide (P1134473-11EN Rev A, 2026), which we read on 2026-11-27. The page numbers are theirs. Where a guide does not settle a point, we say so.
- The origin is the same. The EPL guide puts a field's origin at its upper left corner, on a grid in dots; ZPL's label home is the upper left corner, 0,0, and
^FOsets the upper left of a field. - So are the units: dots, 8 to the millimetre at 203 dpi in ZPL's reference, and the EPL guide writes 3 mm as 24 dots. The label size guide converts inches to dots.
EPL commands and their ZPL
Nbecomes^XA. N clears the image buffer before a new label; ^XA starts a label. The EPL guide asks for a line feed before N, and for setup commands such as q and Q to come before it. (EPL p. 122; ZPL p. 370.)q812becomes^PW812. The label width in dots. On EPL desktop printers, the EPL guide says, q also sets the left margin to (print head width - label width) / 2, which centres the label. ^PW's reference says nothing of the kind, so print one label and check the left edge. (EPL pp. 137, 138; ZPL p. 329.)Rbecomes^LH. R moves the reference point: every later x and y is measured from its left and top margins, in dots. It also makes the image buffer the full width of the print head, which overrides q and its centring. ^LHx,y moves 0,0 for every field after it, so an EPL R value goes straight into ^LH. (EPL pp. 138, 143; ZPL p. 293.)Q406,24becomes^LL406 and ^MNY. Q is the label length and the gap between labels, in dots. ^LL is the length, and ^MN how the printer finds the next label: Y for a gap, M for a black mark (Q with B before the mark's thickness), N for continuous media (Q with a gap of 0). (EPL p. 139; ZPL pp. 294, 307.)A40,30,0,4,2,2,N,"Rack 12, bay 3"becomes^FO40,30^A0N,48^FDRack 12, bay 3^FS. Text: x and y, rotation, font, the width and height multipliers, N or R for reversed, then the data. ^FO is x and y, ^A the font, orientation and height, ^FD the data. EPL's rotations 1, 2 and 3 are 90, 180 and 270 degrees, and ^A's R, I and B are 90 degrees clockwise, 180 and 270. The EPL guide does not say which way its 90 turns, so check a turned field. R, white on black, is ^FR in the field. (EPL pp. 43, 44; ZPL pp. 60, 201, 203.)B40,130,0,1,2,2,100,B,"R12-B03"becomes^BY2^FO40,130^BCN,100,Y,N,N,A^FDR12-B03^FS. A barcode: x and y, rotation, type, narrow bar width, wide bar width, height, B (with its text) or N, then the data. Type 1 is Code 128 with the subsets chosen for you, ^BC's mode A. The narrow bar width is ^BY's module width, and B is ^BC's Y. Code 128 has no wide bar: the EPL guide's table marks its wide bar N, and ^BC has a fixed ratio. For a barcode with wide bars, such as Code 39 (type 3), the wide bar width is in dots and ^BY's ratio is wide over narrow, 2.0 to 3.0: B..,3,2,6 is ^BY2,3.0. At small module widths the printer rounds the ratio, to 2:1 or 2.5:1 for most ratios at 2 dots, so not every EPL pair has a match. (EPL pp. 52, 53; ZPL pp. 94, 148.)LO40,100,732,3becomes^FO40,100^GB732,3,3^FS. A black line: x, y, the length across and the length down. ^GB is a width, a height and a thickness; a line is a box as thick as its shorter side. (EPL p. 118; ZPL p. 210.)LWbecomes^GB with colour W. A white line over what is already there: ^GB's fourth value, W. (EPL p. 120; ZPL p. 210.)LEbecomes^FR in a ^GB field. A line that reverses what is under it. Zebra's ZPL reference says a field with ^FR prints the reverse of its background. We have not drawn ^FR on a ^GB. (EPL p. 117; ZPL p. 203.)LSbecomes^GD. A diagonal line. ^GD draws one across a box of the width and height you give it. (EPL p. 119; ZPL p. 213.)X20,15,4,792,390becomes^FO20,15^GB772,375,4^FS. A box: x and y, the line thickness, then x and y of the far corner. ^GB takes the width and height, so subtract: 792 less 20 is 772. The EPL guide does not say whether the far corner's dot is inside the box, so the ZPL may be a dot smaller. (EPL p. 168; ZPL p. 210.)GWbecomes^GF. A picture: x and y, its width in bytes (8 dots to a byte), its height in rows, then the bytes. ^GF takes the same rows as binary (B) or hex (A), after the byte count, twice, and the bytes a row. (EPL p. 110; ZPL p. 215.)P2becomes^PQ2, then ^XZ. P prints: the number of label sets, then copies of each, which the EPL guide ties to counters. ^PQ's first value is the total number of labels and ^XZ ends the label. So P5,2 is not ^PQ5: with counters, its second value is closest to ^PQ's third, replicates of each serial number, which the print copies guide covers with ^SN. (EPL p. 135; ZPL pp. 324, 375.)Sbecomes^PR. Print speed. S takes a value whose speed depends on the printer model: on a GK420, S4 is 4.0 inches a second. ^PR takes the speed in inches a second, so look the value up in the EPL guide's table for your model: S4 on a GK420 is ^PR4. (EPL p. 144; ZPL p. 326.)Dbecomes~SD or ^MD. Darkness. EPL's D is 0 to 15; ZPL's ~SD is 00 to 30, and ^MD adds to it. Neither guide maps one scale to the other, so we do not: set it on the printer and print one. (EPL p. 88; ZPL pp. 301, 333.)Ibecomes^CI. The character set. EPL's default is DOS code page 437; ^CI 0 to 12 are Zebra's code page 850 with some characters replaced, so there is no exact match for every EPL code page. For UTF-8 text, use ^CI28, as the accented characters guide does. (EPL pp. 31, 112, 113; ZPL pp. 155, 156.)ZT, ZBbecomes^POI, ^PON. Which end of the image prints first. The EPL guide says the default, ZT, prints the top first, which the operator sees upside down. Zebra's ZPL reference, on its EPL legacy modes, calls ^PON "EPL ZB mode", so ZB is ^PON and ZT the other way, ^POI. We have not printed either. (EPL p. 170; ZPL pp. 322, 695.)
One label, translated
An EPL2 label for 4 × 2 inch stock with gaps, a box, a line of text, a rule and a Code 128 barcode, two copies:
q812
Q406,24
N
X20,15,4,792,390
A40,30,0,4,2,2,N,"Rack 12, bay 3"
LO40,100,732,3
B40,130,0,1,2,2,100,B,"R12-B03"
P2The same label in ZPL, a line for each EPL command:
^XA
^PW812
^LL406
^LH0,0
^MNY
^FO20,15^GB772,375,4^FS
^FO40,30^A0N,48^FDRack 12, bay 3^FS
^FO40,100^GB732,3,3^FS
^BY2^FO40,130^BCN,100,Y,N,N,A^FDR12-B03^FS
^PQ2
^XZ- The empty first line of the EPL is the line feed its guide asks for before
N. ZPL needs none:^XAstarts the label. q812andQ406,24became^PW812,^LL406and^MNY, labels with a gap.^LH0,0is what EPL'sR0,0would be; this EPL has noR, and usesqinstead. It puts 0,0 back at the corner, which the label size guide explains, along with why^LLdoes not change the length of labels with gaps.- The box's far corner, 792,390, became a width and height, 772 × 375. The boxes and lines guide covers
^GB. B40,130,0,1,2,2,100,Bbecame^BY2and^BCN,100,Y,N,N,A: 2 dot modules, 100 dots tall, with its text under the bars. The Code 128 guide works out the width.P2became^PQ2, before^XZ. The print copies guide shows why after^XZit prints one.- The ZPL has no
^PO, and we left it out on purpose. The EPL has noZ, so by the EPL guide it printsZT, its default (p. 170), which the map above makes^POI. But the ZPL guide says a current printer powers on in^PON, "EPL ZB mode", and that the older 2824 and 2844 printers default toZB(p. 695). The two guides do not agree on which way your EPL printed, so print one label from each and add^POIif the ZPL comes out upside down against the EPL.
What we could check
- Labelary does not draw EPL. Sent the EPL above, its ZPL API answered
404:ERROR: Requested 1st label but ZPL generated no labels. So the EPL and the ZPL were never drawn side by side, and we do not say they print the same. - It drew the ZPL as 2 labels, for
^PQ2, each with 26,874 black dots. zxing-cpp read the barcode asR12-B03, and its bars ran from x 40 to 263. - That is Labelary's drawing, not a printed label. Print one and scan it before you replace the EPL.
What does not carry over
- The fonts. EPL's fonts 1 to 5 are fixed-width dot fonts: font 4 at 203 dpi is 14 × 24 dots a character, and the multipliers stretch it. ZPL's font 0 is not one of them. At 48 dots, the height of font 4 doubled, our line of text was 282 dots wide in Labelary; in font 4 at 2 × 2 its 14 characters take 392. Match the height, then widen with
^A's width value:^A0N,48,66drew the same line 386 dots wide in Labelary. Print one to check. The font size guide converts points to dots and explains the width. - Special characters. EPL's data sits in quotes, with a backslash before a quote or a backslash. In ZPL a
^or~in the data starts a command; the special characters guide shows how to print them with^FH. - Centring. EPL's
qcentres a label narrower than the print head, and EPL'sRturns that off and sets the margins itself; nothing in^PW's reference centres. An EPLRvalue goes straight into^LH. For EPL that relied onq, the offset it gave is (print head width - label width) / 2 dots: if the ZPL prints off to one side, move it that far with^LH. - Graphics.
GW's bytes can go into a^GFas they are, but the EPL guide does not say whether a 1 bit is black or white. In^GFa 1 is a black dot, as the logos and images guide shows; in the EPL Labelary wrote for us, below, a 0 was. Try one graphic before you convert them all, or make the^GFagain from the original image with the logos guide's script. - Stored forms, variables and counters. EPL keeps forms on the printer and fills them from data that follows. The templates guide covers ZPL's stored formats, and the multiple labels guide its serial numbers. We have not mapped one to the other.
Labelary converts the other way
Labelary's API can answer in EPL as well as PNG and PDF. Sent our ZPL with Accept: application/epl, it answered 36,396 bytes: N, then one GW16,15,97,375, a picture of the whole label, then P1.
- Its bars were dot for dot the same as Labelary's PNG. 451 dots differed, along the edges of the text, mostly where the PNG is grey.
- It is ZPL to EPL, as a picture, not EPL to ZPL. And it ended in
P1, though the ZPL asked for two copies. - Everything you send goes to Labelary. The ZPL to PDF guide covers its plans and limits.
Printers that take both, and switching
The EPL guide says a Zebra G-Series printer takes EPL, ZPL and SGD commands without being told to switch, as long as each is sent as a separate file (EPL p. 177). The setting behind it is device.languages (EPL p. 184, ZPL p. 723). Ask the printer for it:
! U1 getvar "device.languages"And set it to ZPL only:
! U1 setvar "device.languages" "zpl"- The ZPL guide gives the default as
epl_zpl, both languages, and listseplandzplamong the values. It says not every printer takes every value:! U1 getvar "allcv"lists the ones yours does. - The EPL guide says setting it works only on G-Series printers. Its own example of the set line shows
getvar; the line above is the ZPL guide's. - We have sent neither to a printer. Ask Zebra which languages your model takes before you rely on switching.
Or rebuild the label in a design tool
The accepted Stack Overflow answer designs the label again in ZebraDesigner, chooses a ZPL printer driver and prints to a file, which then holds the ZPL. That gives ZPL for a label you can redraw, not for EPL your code writes. We have not tried it.
The same label from data
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.
1{2 "config": {3 "size": "4x2",4 "copies": 25 },6 "data": {7 "location": "Rack 12, bay 3",8 "code": "R12-B03"9 },10 "templates": [11 {12 "type": "Box",13 "coords": [20, 15],14 "width": 772,15 "height": 375,16 "thickness": 417 },18 {19 "type": "Text",20 "dataPath": "location",21 "coords": [40, 30],22 "font": "0,48"23 },24 {25 "type": "Line",26 "coords": [40, 100],27 "length": 732,28 "direction": "h",29 "thickness": 330 },31 {32 "type": "BarCode",33 "dataPath": "code",34 "coords": [40, 130],35 "style": "code128",36 "moduleWidth": 2,37 "height": 100,38 "hri": "below"39 }40 ]41}And the ZPL that comes back, ready to send to the printer:
^XA^MCY^XZ
^XA
^SZ2
^MMT
^MNY
^LL406
^PW812
^LH0,0
^FO20,15^GB772,375,4^FS
^CF0,48^FO40,30^FDRack 12, bay 3^FS
^FO40,100^GB732,3,3^FS
^BY2,2,59^FO40,130^BCN,100,Y,N,N,A^FDR12-B03^FS
^PQ2
^XZzeepler takes JSON, not EPL: a request is JSON, and its elements are Text, BarCode, QRCode, Line and Box. This request makes the label above, with copies for P2.
- In Labelary it drew the same dots as the plain ZPL above, 2 labels, and zxing-cpp read
R12-B03. - What it cannot do: read EPL, print a picture as
GWdoes, reverse a field asLEorA'sRdo, draw a diagonal line, or print EPL's fonts. It makes six label sizes, all at 203 dpi, so an EPL label of another size has no match.
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
200with the ZPL as plain text. A request the API cannot turn into a label answers400with 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.
Related guides
- QR code size in ZPL: How ^BQ magnification sets the size of a QR code, and how to work out the size in dots.
- Printing ^, ~ and _ in ZPL: Why a caret or tilde in your data cuts the field short, and how ^FH prints them.
- Font size in ZPL: Setting text height with ^A and ^CF, converting points to dots, and why ^CF carries over.
- Send ZPL to a Zebra printer from C#: Send ZPL from .NET to a network printer on port 9100, or to a USB printer through the Windows spooler, without the driver redrawing it.
- Code 128 barcodes in ZPL: Set a Code 128 barcode's width and height with ^BY and ^BC, work out its width in dots, and pick subsets A, B and C.
- Accented characters in ZPL (^CI28): Print é, ç, ô and € with ^CI28, switch the printer back with ^CI0, and what to do on older firmware.
- Send ZPL to a Zebra printer from Python: Send ZPL from Python to a network printer on port 9100, or to a USB printer through the Windows spooler, without the driver redrawing it.
- Change a barcode to a QR code in ZPL: Swap ^BC for ^BQ, start the field data with QA, so the first characters scan, and reset the ^BY left over from the barcode.
- Send ZPL to a Zebra printer from Node.js: Send ZPL from Node.js to a network printer on port 9100 or to a USB printer through a Windows printer share, and print from a web page through your server.
- Label size and origin in ZPL (^PW, ^LL, ^LH): Set the label size in dots with ^PW and ^LL, move 0,0 with ^LH, and stop the last label's settings moving this one.
- Templates in ZPL: store a format with ^DF, fill it with ^XF: Store a label layout on the printer with ^DF and ^FN, fill it with ^XF, and what prints when a field or the format is missing.
- Several labels in one ZPL job: Send several different labels in one job, stop each one inheriting the last one's font and barcode settings, and number a run with ^SN and ^PQ.
- EAN-13 and Code 93 barcodes in ZPL: Print EAN-13 with ^BE and Code 93 with ^BA, and the data each one changes: a replaced check digit, and characters Code 93 cannot hold.
- Print copies of a ZPL label with ^PQ: Print several copies of one label with ^PQ, why ^PQ after ^XZ prints only one, and each serial number twice with ^SN.
- Center text in ZPL with ^FB: Center text of any length with ^FB, why centered text sits a little left, and text too long for the block.
- Center or right-align a barcode in ZPL: Right-align a barcode with the third value of ^FO, center one by working out its width, and why ^FB does not move it.
- Wrap text and new lines in ZPL: Wrap long text with ^FB, start a new line with \&, and stop ^FB writing over its last line or cutting text off.
- Rotate text and barcodes in ZPL: Turn text and barcodes with N, R, I and B, where ^FO and ^FT put a turned field, ^FW and ^POI, and why both stay set.
- Preview ZPL without a printer: See a label before printing it with Labelary's viewer or API, what zeepler's playground shows, and what no preview can tell you.
- Boxes, lines, underline and bold in ZPL (^GB): Draw boxes and lines with ^GB, print white on black with ^FR, underline text with a line, and make text bolder.
- Logos and images in ZPL (^GF, ~DG, ^XG): Print a logo with ^GF, turn a PNG into hex, keep it under the size limit, and store it once with ~DG to print with ^XG.
- GS1-128 barcodes in ZPL, with the check digit: Print GS1-128 with ^BC and FNC1, work out the mod 10 check digit of a GTIN or SSCC, separate fields that vary in length, and what the printer adds itself.
- 300 dpi printers, and the same ZPL on 203 and 300 dpi: Why a 203 dpi label prints smaller at 300 dpi, scaling it by 1.5 and what does not scale exactly, ^MU in millimetres, and reading the printer's resolution.
- Comments in ZPL: ^FX: Write a comment with ^FX, why a caret inside one runs as a command, comments outside ^XA and ^XZ, and why // is not a comment.
- Emulate a Zebra printer for testing: A stand-in printer on port 9100 in a few lines of Python or Node.js, pointing your send code at it, checking what it caught in Labelary, and what a stand-in cannot test.
- Convert ZPL to PDF or PNG: Labelary's API turns ZPL into a PDF, one label to a page, or a PNG of one label: curl, Python and Node.js, its limits, and what it means to send it your labels.
- Convert a PDF to ZPL: Draw each page of the PDF as dots at the printer's resolution and send them as ^GF: a Python script, sizing, grey, the ^GF size limit, and why the label prints as a picture.
- Convert HTML to ZPL: Two ways from an HTML label to ZPL: draw the page in a headless browser and send the dots as ^GF (a Node.js script), or write the label as ZPL fields, with which HTML and CSS ideas carry over and which do not.
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.