Skip to main content

Convert ZPL to PNG

This API rasterizes ZPL (Zebra Programming Language) into a PNG image. Use it to preview labels before printing, archive generated ZPL as images, or show a label in a web app without a printer on the network.

Typical uses include QA of HTML/PDF conversions, debugging barcodes and layout, and storing a visual copy of each printed label.

Try it in the ZPL to PNG online demo.

API usage

Endpoint: POST https://html-to-zpl.p.rapidapi.com/zpl2png

Set the API key from RapidAPI in the X-RapidAPI-Key header.

Send parameters in the POST body as JSON (Content-Type: application/json) or as form fields (Content-Type: application/x-www-form-urlencoded). The response is a PNG (Content-Type: image/png).

On a private API server, the same request is POST http://SERVER:8000/api/zpl2png.

Required parameters

ParameterDescriptionExample
widthLabel width, in the unit given by unit (inches by default).4
heightLabel height, in the unit given by unit (inches by default).6
zplThe ZPL source as UTF-8 text.^XA^FO50,50^A0N,40,40^FDHello^FS^XZ
note

ZPL is almost always plain text, so send it in zpl. If you already have it encoded as base64, you can send zplBase64 instead (no data-URL prefix, no line breaks).

Optional parameters

ParameterRequiredDescriptionExample
rotateoptionalRotate the PNG. One of 0 (default), 90 (right), 180, 270 (left).90
unitoptionalUnit for width and height. One of:
  • in (default) — inches
  • mm — millimeters
  • dots — printer dots
in

Match width and height to the label the ZPL was written for. ^PW and ^LL in the ZPL do not replace these parameters.

The maximum label side is 15 inches. Developer (free) requests include a watermark; paid plans and private VMs do not.

Command-line example (curl)

Replace API_KEY with your key from RapidAPI.

JSON — a 4×2″ label:

curl --request POST \
--url https://html-to-zpl.p.rapidapi.com/zpl2png \
--header 'content-type: application/json' \
--header 'x-rapidapi-host: html-to-zpl.p.rapidapi.com' \
--header 'x-rapidapi-key: API_KEY' \
--data '{
"width": 4,
"height": 2,
"zpl": "^XA^FO40,40^A0N,50,50^FDZPL to PNG^FS^FO40,120^A0N,30,30^FDhtmltozpl.com^FS^XZ"
}' \
--output label.png

From a .zpl filezpl@filename reads the file as the zpl field:

wget https://www.htmltozpl.com/img/sample-label.zpl
curl --request POST \
--url https://html-to-zpl.p.rapidapi.com/zpl2png \
--header 'content-type: application/x-www-form-urlencoded' \
--header 'x-rapidapi-host: html-to-zpl.p.rapidapi.com' \
--header 'x-rapidapi-key: API_KEY' \
--data-urlencode 'width=4' \
--data-urlencode 'height=6' \
--data-urlencode '[email protected]' \
--output sample-label.png

You can download the sample 4×6″ ZPL used above.

With rotation — turn the PNG 90° clockwise:

curl --request POST \
--url https://html-to-zpl.p.rapidapi.com/zpl2png \
--header 'content-type: application/json' \
--header 'x-rapidapi-host: html-to-zpl.p.rapidapi.com' \
--header 'x-rapidapi-key: API_KEY' \
--data '{
"width": 4,
"height": 6,
"rotate": 90,
"zpl": "^XA^FO50,50^A0N,40,40^FDHello^FS^XZ"
}' \
--output label-rotated.png
tip

The HTML to ZPL and PDF to ZPL demos already use this endpoint for the on-page preview. After you generate ZPL, the preview image is a PNG from /zpl2png.