HTML to ZPL Quick Start Guide
This API service can convert any HTML document into ZPL code compatible with Zebra label printers. It executes style sheets, loads images, and even executes JavaScript - just like you're used to from your web browser. The HTML to ZPL API is a great way to create custom label templates for Zebra printers without resorting to writing ZPL yourself.
API Usage
The API method and endpoint is POST https://html-to-zpl.p.rapidapi.com/html2zpl
The API key provided by Rapid API must be set in the HTTP header X-RapidAPI-Key
.
The API call returns raw ZPL data. You can save it to a file for further processing, or send it directly as-is to a Zebra printer to print the label.
Parameters
The following parameters can be set via the body of a POST
request,
either as JSON (using the content-type application/json
)
or form-encoded (using the content-type: application/x-www-form-urlencoded
header).
Parameter Name | Required | Description | Example |
---|---|---|---|
height | yes | The height of the label in inches. | 6 |
width | yes | The width of the label in inches. | 4 |
html | yes | The HTML content that is rendered on the label. You can include images or execute JavaScript. We recommend that you embed or inline external resources as Data URLs, to avoid having to host resources. | <h1 font-size:40pt;margin-top:0.5in;>Hello World!<h1> <p style="margin-top:1.2in; font-size:25pt;">ZPL label generated by <u>htmltozpl.com</u></p> |
dpi | no | The Zebra printer resolution in dpi (dots per inch):
| 203 |
Print Quality Settings
Parameter Name | Required | Description | Example |
---|---|---|---|
darkness | optional | An integer value between 0 and 30. Sets the printer darkness. This is equivalent to setting the darkness in the Zebra printer web configuration or driver. | 15 |
dpi | optional | The Zebra printer resolution in dpi (dots per inch):
| 203 |
speed | optional | An integer value between 2 and 12 that determines the media speed during printing in inches per second. This is equivalent to the corresponding print rate setting in the Zebra printer web configuration or driver. | 2 |
Lowering the print speed improves the quality, especially for small fonts and barcodes.
Example using the Command Line
A brief example that can be executed on the CLI is provided below. You will need to have curl installed on your machine.
To run this example you will need an API Key. Please subscribe to the API if you don't have one yet. Replace API_KEY
in the example with your key.
This command will generate the ZPL code for a 4" x 2" label with some sample text:
curl --request POST \
--url https://html-to-zpl.p.rapidapi.com/html2zpl \
--header 'content-type: application/json' \
--header 'x-rapidapi-key: API_KEY' \
--data '{ "width":"2", "height":"2", "html":"<div style=\"margin: 0.25in; border: 1px solid black;\">ZPL by htmltozpl.com</div>" }'
After a few seconds, the API will send back the encoded ZPL data:
^XA ^PW406^LL406^LS0 ^LH0,0 ^FO0,0^GFA,20706,20706,51, ,:::::::::::::::::::::::::::::::::::::::::::::::::R0G1iUFGES0R0G3iUFGES0:R0G3G8iT0G6S0R0G3G8W0G8hV0G6S0R0G3G8JFG3HFG8G0G7GFGEJ0G3GChV0G6S0R0G3G9JFG1IFG0G3GFGCJ0GFGChV0G6S0R0G3G9GCG0G1GEG0G7G8GFG8G0GFK0G3GChV0G6S0R0G3G9G8G0G3GCG0G7G8G3GCG0GFK0G3GChV0G6S0R0G3G9H0G7GCG0G7G8G1GEG0GFK0G3GChV0G6S0R0G3G9H0G7G8G0G7G8G1GEG0GFK0G3GChV0G6S0R0G3G8H0GFH0G7G8G1GEG0GFK0G3GChV0G6S0R0G3G8G0G1GFH0G7G8G1GEG0GFK0G3GCG7hU0G6S0R0G3G8G0G1GEH0G7G8G1GEG0GFK0G3GDGFGCG7GFG0G7GChO0G6S0R0G3G8G0G3GCH0G7G8G1GEG0GFK0G3HFGEG1GEG0G3G8hO0G6S0R0G3G8G0G7GCH0G7G8G3GCG0GFK0G3GEG1GEG0GEG0G3hP0G6S0R0G3G8G0G7G8H0G7GCGFG8G0GFK0G3GCG0GFG0GFG0G3hP0G6S0R0G3G8G0GFI0G7HFH0GFK0G3GCG0GFG0G7G0G6hP0G6S0R0G3G8G1GEI0G7G8I0GFK0G3GCG0G7G0G7G0G6hP0G6S0R0G3G8G3GEI0G7G8I0GFK0G3GCG0G7G0G3G8GChP0G6S0R0G3G8G3GCI0G7G8I0GFK0G3GCG0G7G0G3G8GChP0G6S0R0G3G8G7G8I0G7G8I0GFK0G3GCG0G7G0G1HChP0G6S0R0G3G8GFG8G0G1G8G7G8I0GFH0G1H0G3GCG0G7G0G1GDG8hP0G6S0R0G3G8GFH0G1G0G7G8I0GFH0G1H0G3GCG0G7G0G1GFG8hP0G6S0R0G3G9GEH0G1G0G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8G6G0G7G8G1GCG0GEgL0G6S0R0G3HFGBGFGCG7GCGFGEG7GFGBGFG9GFGCG3GEG0G7GFG8G3IFG1HFG8G3GFGCG7G8G1GFGCG0G3GFGCG1GFGEHFG3GFG8gK0G6S0R0G3G8X0G1GCK0G1GDGEJ0G2H0G7I0G7gT0G6S0R0G3G8gK0G1GChM0G6S0::R0G3G8gK0G3GChM0G6S0:R0G3G8gK0HFhM0G6S0R0G3G8iT0G6S0R0G3iUFGES0:R0G1iUFGES0,::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::^FS^XZ
This ZPL code can be sent directly (raw) to a Zebra printer for printing. If the printer is connected via network, you can send the string directly over a TCP socket (default port 9100) to the printer. Please check the FAQ for code samples.
To see a preview of the ZPL you can use the viewer at Labelary. Be sure to specify the correct size for the label.