Merge fields
Merge fields are placeholders in a label template that get their values at conversion or print time.
Syntax
Section titled “Syntax”A merge field goes in the content of a variableText or barcode component in LabelZoom XML:
<component xsi:type="variableText" x="20" y="30" fontSize="10"><![CDATA["Qty: ${qty} of ${total}"]]></component><component xsi:type="barcode" x="20" y="90" barcodeStyle="Code128"><![CDATA["{{sscc18}}"]]></component>| Rule | Example |
|---|---|
| Put the whole content in double quotes. Without them, every field on the label renders blank. | "${sku}" |
| Wrap the content in CDATA. | <![CDATA["${sku}"]]> |
| Combine text and fields inside the quotes. | "Qty: ${qty} of ${total}" |
Only \n and \" are escapes. Any other backslash prints as is. |
"Line 1\nLine 2" |
{{name}} is an alias for ${name}. |
"{{sscc18}}" |
Use schemaVersion v2. |
<labelZoomXml schemaVersion="v2" …> |
Field names
Section titled “Field names”Use letters, digits, and underscores. A name is read literally and trimmed, so ${ sku } reads the key sku.
A dot is part of the name, not a path: ${order.id} reads a top-level key named order.id. Flatten nested data before you send it.
Unsupported expressions
Section titled “Unsupported expressions”Everything between the braces is one field name, so these forms aren’t evaluated:
| Form | Example | Result |
|---|---|---|
| Nested path | ${order.items.sku} |
null |
| Array index | ${items[0]} |
null |
| Arithmetic | ${qty * price} |
null |
| Function | ${upper(sku)} |
null |
| Default value | ${sku ?: 'N/A'} |
null |
+ concatenation |
"PO " + ${po} |
Every field renders blank. Write "PO ${po}". |
| Formatting, padding, substrings | None | Not available. |
Substitution runs once, so a value that contains ${...} prints as is. Compute values in your application and send finished strings.
Missing values
Section titled “Missing values”A field whose key isn’t in the data prints the literal text null. To print nothing, send an empty string, such as {"qty":""}. If you omit data, every field prints null.
Built-in fields
Section titled “Built-in fields”| Field | Value |
|---|---|
${LABEL_NUMBER} |
The index of the current label, starting at 0. |
${LABEL_COUNT} |
The total number of labels. |
With two data entries, "Label ${LABEL_NUMBER} of ${LABEL_COUNT}" prints Label 0 of 2, then Label 1 of 2.
ZPL placeholders
Section titled “ZPL placeholders”In a ZPL template, mark merge fields in ^FD instead of using ${...}:
| ZPL | Result |
|---|---|
^FD~cponum,20~^FS |
Merge field cponum, with a maximum length of 20. |
^FD{BFFNAME}^FS |
Merge field BFFNAME. |
^FD text without either form |
Static text. |
^FN, ^SN |
No merge field. ^SN prints its starting value. |
Address blocks
Section titled “Address blocks”An addressBlock component formats a postal address for its country. Its content is a bare field name, with no quotes or ${}:
<component xsi:type="addressBlock" x="20" y="200" fontSize="10" useLocalizedAddressFormat="true" showContactName="true"><![CDATA[ship_to]]></component>The matching key holds an object with these twelve keys. All are optional, and other keys are ignored:
[ { "sku": "A-100", "ship_to": { "name": "ACME Corp", "honorific": "Ms.", "first_name": "Dana", "last_name": "Reyes", "line1": "1 Main St", "line2": "Suite 400", "line3": "", "district": "", "city": "Austin", "state": "TX", "zip": "78701", "country": "US" } }]Outside an address block, don’t reference a nested object or array with ${...}.
Add merge fields in Studio
Section titled “Add merge fields in Studio”To add a merge field in LabelZoom Studio:
- Double-click a variable text or barcode element to open the Expression Editor.
- Select Variable Text and enter a field name. To combine text and fields, select Dynamic Expression and enter an expression such as
"Order: ${ordnum}". - Click OK.
- Optional: To publish the label as a Cloud Print template, click File > Publish as Print Template. The dialog lists the label’s merge fields.

In the web designer, type ${name} in the Content box, or click Insert field. Your data’s keys must match the template’s merge field names.
Supply values
Section titled “Supply values”| Endpoint | Send values as | Details |
|---|---|---|
POST /api/v2/convert/{source}/to/{target} |
The data parameter, a JSON array |
Variable data |
POST /api/v3/printers/{printerId}/templates/{templateId}/print, POST /api/v3/templates/{templateId}/convert |
The body, an object or an array of objects | Templates |
On the conversion API, a data value that isn’t an array returns 400 params.data must be a JSON array, with one entry per output label.
Troubleshooting
Section titled “Troubleshooting”| Symptom | Fix |
|---|---|
| Every merge field is blank. | Put each expression in double quotes: "${sku}", not ${sku}. |
A field prints null. |
Send a key that matches the name exactly, including case. A dotted name is one key, and expressions aren’t supported. |
400 params.data must be a JSON array |
Wrap data in an array, even for one label: [{"sku":"A-100"}]. |
| A ZPL template ignores the data. | Mark each field in ^FD with ~name,len~ or {NAME}. |
What’s next
Section titled “What’s next”- Print When conditions: show or hide an element based on its data.
- Conversion parameters: every option the conversion API accepts.
- Cloud Print templates: print and render published templates.