Skip to main content
Box Doc Gen template tags currently support English only. Test your templates to verify they meet your language requirements before production use.
Template tags let you create document templates that automatically fill in with data. When you generate a document, Box Doc Gen finds the tags in your template, matches them to fields in your JSON input, and replaces each tag with the corresponding value.

1. Text tags

A text tag is any data field of type, string, number, or date. In the example below, you can turn id, date, customerId, customerName, currency, amount into text tags.
In the output document generated, all the template tags will be replaced with the input data.
Box Doc Gen tags do not support spaces or hyphens between key words in the tag. For example, **{{first name}}** or **{{first-name}}** are not supported.

Optional tags

Default values

Formatting text tags

Rich text

Box Doc Gen enables you to generate documents with rich text. If the input JSON data contains HTML tags such as bold, italic, underline, line breaks, paragraphs, anchors, images, or tables, Doc Gen automatically interprets them as rich text and applies the relevant formatting.
HTML TagsJSON dataOutput
Bold{ “company”: “<b>Acme Inc.</b> A fictional company that features prominently in the Road Runner show as a running gag. Phone:<b> 999-999-9999</b>” }Acme Inc. A fictional company that features prominently in the Road Runner show as a running gag. Phone: 999-999-9999
Italic{ “company”: “<i>Acme Inc.</i> A fictional company that features prominently in the Road Runner show as a running gag. Phone:<i> 999-999-9999</i>” }Acme Inc. A fictional company that features prominently in the Road Runner show as a running gag. Phone: 999-999-9999
Underline{ “company”: “<u>Acme Inc.</u> A fictional company that features prominently in the Road Runner show as a running gag. Phone:<u> 999-999-9999</u>” }Acme Inc. A fictional company that features prominently in the Road Runner show as a running gag. Phone: 999-999-9999
Bold, Italic and Underline{ “company”: “<b><i><u>Acme Inc.</u></i></b>A fictional company that features prominently in the Road Runner show as a running gag. Phone:<b><i><u> 999-999-9999</u></i></b>” }Acme Inc. A fictional company that features prominently in the Road Runner show as a running gag. Phone: 999-999-9999
Strong{ “company”: “<strong>Acme Inc.</strong> A fictional company that features prominently in the Road Runner show as a running gag. Phone:<strong> 999-999-9999</strong>” }Acme Inc. A fictional company that features prominently in the Road Runner show as a running gag. Phone: 999-999-9999
Span{ “company”: “<span>Acme Inc.</span> A fictional company that features prominently in the Road Runner show as a running gag. Phone:<span> 999-999-9999</span>” }Acme Inc. A fictional company that features prominently in the Road Runner show as a running gag. Phone: 999-999-9999
Emphasized{ “company”: “<em>Acme Inc.</em> A fictional company that features prominently in the Road Runner show as a running gag. Phone:<em> 999-999-9999</em>” }Acme Inc. A fictional company that features prominently in the Road Runner show as a running gag. Phone: 999-999-9999
Line breaks{ “company”: “<b>Acme Inc.</b>  \n A fictional company that features prominently in the Road Runner show as a running gag. \n Phone:<b> 999-999-9999</b>” }Acme Inc.  
A fictional company that features prominently in the Road Runner show as a running gag. 
Phone: 999-999-9999
Paragraphs{ “company”: “<b>Acme Inc.</b>  <p> A fictional company that features prominently in the Road Runner show as a running gag. </p>  <p> Phone:<b> 999-999-9999</b>”</p> }Acme Inc. 
A fictional company that features prominently in the Road Runner show as a running gag. 
Phone: 999-999-9999
Ordered list<ol><li>Blue</li><li>Green</li><li>Red</li></ol>
  1. Blue
  2. Green
  3. Red
Unordered list<ul><li>Blue</li><li>Green</li><li>Red</li></ul>
  • Blue
  • Green
  • Red
Table{ “invoice”: { “summary”: “<table><tr><td>Name</td><td>Qty</td></tr><tr><td>A4 Papers</td><td>100</td></tr><tr><td>Ink cartridge</td><td>40</td></tr><tr><td>Adhesive tape</td><td>20</td></tr></table>” } }
NameQuantity
A4 Papers100
Ink cartridge40
Adhesive tape20

2. Image tags

Doc Gen enables you to embed any image file in Box into the generated document. To do this, you will need to follow the following steps:

1. Upload the image file to Box

The image file being used for document generation has to be uploaded to Box. Generating documents via API If you are using a service account to generate the document via APIs, ensure the service account has access to the file.

2. Author the Doc Gen template

Doc Gen enables you to generate documents using images in the following ways:
  • Generating documents from a placeholder image
  • Generating documents with HTML images

Generating documents from a placeholder image

Authoring a Doc Gen template using Add-in for Microsoft Word To insert an Image tag using the add-in:
  1. In the Box Doc Gen Template Creator add-in, create an image tag using your desired placeholder image
  2. Navigate to the Document Tags > Image Tags.
  3. In the document, select the area to insert an Image tag.
  4. Double-click the image tag to insert it.
The result is a placeholder image, which can be dynamically replaced by the input data from the Box Doc Gen API, or any other upstream systems.
Gray placeholder image with a circle and two mountain shapes.
The dimensions, and alignments of the placeholder image can be altered using Microsoft Word functions. These properties are retained in the output document. The placeholder image has the following code added to the image under “Alt Text”. To view it, select the image, right-click, and then select View Alt Text.
  • The image-path - is the key field for the Image from the JSON Payload used to make a request to Generate a document.
  • You can also add a placeholder image by simply dragging and dropping it into the document or inserting an image placeholder. However, make sure to manually include the required code in the ALT TEXT field.
Repeating images within a for-loop: To generate a document with multiple images in a for-loop, ensure the image is wrapped in a For function as below,
Repeating images within a table-loop: To generate a document with multiple images in a table-loop, ensure the image is wrapped in a Table function as below,
{{ tablerow item in multipleImages }}
{{ item.name }}Embedded image whose Alt Text includes JSON with image-path
{{ endtablerow }}
Ensure to include the image path in the ALT TEXT section of the image

Generating documents with HTML images

To generate a document with an HTML image from the JSON payload, include a text tag in the template.
This method only supports generation of simple images, and does not support generation of repeating images in For-loops and Table-loops.

3. Create the JSON payload to generate the document

Generating documents from a placeholder image

To generate a document with an image file in Box, use the following schema:
  1. Key used in the Placeholder image (Ex: singleImage)
  2. id - to pass the file id of the Image file in Box
  3. type - to signify that this is an image file to be embedded in the document
The image file id mentioned here should refer to your file id in Box.
Generating a document from a Placeholder with multiple images To generate a document with multiple image files in Box, run an array of image schema as shown below,

Generating documents with HTML images

To include an image from Box in your document using an HTML image tag, define the JSON schema in the following format:
In this example:
  • file://[FILE_ID] refers to the file ID of the image stored in Box
  • height and width define the display size of the image
  • alt specifies the alternative text for the image

4. Make a document generation request

Doc Gen enables you to create documents with embedded images sourced directly from Box. You can include images in your generated documents using one of the following methods:
  • Box Doc Gen API – Generate documents with images programmatically. Refer to the Box Doc Gen API documentation for step-by-step guidance.
  • Box Doc Gen Web App – Create documents with embedded images through the web interface. See the documentation for detailed instructions.
Salesforce Integration – Generate documents with images by referencing a Box file ID. Ensure the required JSON schema pattern is followed. For setup and usage, refer to the Salesforce integration documentation.

3. Table tags

An array from the input data can be used to generate and dynamically format a table. In the following example:
  • items is an array that can be rendered as a dynamic table.
  • id, name, quantity, price, amount are the variables within the array that can be rendered as individual columns to the dynamic table.

Document Template

The document template with inserted tags will look as follows:
IdNameQtyPrice
{{tablerow item in invoice.items}}
{{item.id}}{{item.name}}{{item.quantity}}{{item.price}}
{{endtablerow}}

Output

Box Doc Gen automatically identifies the table tags added to the document template, matches them with the fields in the input JSON data, and performs a few iterations to generate a complete table for the input data. The output table on the generated document will look as follows:

4. Nested tables

Nested tables let you generate a dynamic table inside another dynamic table using related nested JSON arrays. Key points:
  • tablerow … endtablerow repeats table rows. One item becomes one row.
  • for … endfor repeats text in place. Use it inside a cell, or around a whole table.
  • expenses[0] is the first expense. Counting starts at 0, so the second expense is expenses[1].
The sample data has four levels:
  • Event: name, date, and currency
  • Expenses: Food & Supplies in Amsterdam, and Furniture in London
  • Category items: the line items of each expense, such as Apples and Chairs
  • Extra items: trays, cartons, packets, and boxes for each line item
The following JSON serves as input for the nested table examples:

Example 1: List the items inside the category row

The table has one row per expense. The last cell lists the items of that expense, one field per line, so the items stay stacked in that cell.
{{ tablerow x in expenses }}
{{x.categoryName}}{{x.categoryValue}}{{x.city}}{{ for y in x.categoryItems }}
{{y.itemName}}
{{y.itemValue}}
{{ endfor }}
{{ endtablerow }}
Output

Example 2: Display only the first expense

The table reads items from expenses[0] only, which is Food & Supplies in Amsterdam. The Furniture expense is left out.
{{ tablerow a in expenses[0].categoryItems }}
{{a.itemName}}{{a.itemQty}}{{a.itemValue}}
{{ endtablerow }}
To print the London items instead, use expenses[1].categoryItems. Output

Example 2.1: Display one row per item for every expense

An inner table loop sits inside an outer table loop. Box Doc Gen prints the Amsterdam items first, then the London items.
{{ tablerow x in expenses }}
{{ tablerow a in x.categoryItems }}
{{a.itemName}}{{a.itemQty}}{{a.itemValue}}
{{ endtablerow }}
{{ endtablerow }}
Example 2 prints the first expense only. This example prints every expense. Output

Example 3: Add the event name, date, and currency

Rows above the table loops print once. The currency tag sits in the repeating row, so it prints on every item.
{{eventName}}
{{eventDate}}
{{ tablerow x in expenses }}
{{ tablerow b in x.categoryItems }}
{{b.itemName}}{{b.itemQty}}{{currency}} {{b.itemValue}}
{{ endtablerow }}
{{ endtablerow }}
Output
Developer Conference
2026-05-12
Apples60$ 30
Napkins200$ 20
Chairs40$ 800
Tables10$ 1200

Example 4: Display every category name on each item row

This template produces the same item rows as Example 3, plus a cell that lists every category name with for z in expenses.
{{eventName}}
{{eventDate}}
{{ tablerow x in expenses }}
{{ tablerow c in x.categoryItems }}
{{c.itemName}}{{c.itemQty}}{{currency}} {{c.itemValue}}{{ for z in expenses }}
• {{z.categoryName}}
{{ endfor }}
{{ endtablerow }}
{{ endtablerow }}
The loop reads the full expenses list, so both category names appear on every row. The event name and date still print once above these rows. Output
Developer Conference
2026-05-12
Apples60$ 30• Food & Supplies
• Furniture
Napkins200$ 20• Food & Supplies
• Furniture
Chairs40$ 800• Food & Supplies
• Furniture
Tables10$ 1200• Food & Supplies
• Furniture

Example 5: Add extra items for each line item

The extraItems array sits inside the line item. The loop in the last cell prints the extra items for that row only.
{{eventName}}
{{eventDate}}
{{ tablerow x in expenses }}
{{ tablerow d in x.categoryItems }}
{{d.itemName}}{{d.itemQty}}{{currency}} {{d.itemValue}}{{ for w in d.extraItems }}
{{w.itemName}} {{w.itemValue}}
{{ endfor }}
{{ endtablerow }}
{{ endtablerow }}
Output
Developer Conference
2026-05-12
Apples60$ 30Trays 5
Cartons 3
Napkins200$ 20Packets 2
Chairs40$ 800Boxes 15
Tables10$ 1200Boxes 20

Example 6: Create one table per expense

The for loop sits outside the table. Box Doc Gen repeats the whole table once per expense, so the output has two tables. {{ for x in expenses }}
{{ tablerow e in x.categoryItems }}
{{e.itemName}}{{e.itemQty}}{{e.itemValue}}
{{ endtablerow }}
{{ endfor }} Output
These tables have no heading of their own. To label each one, add {{x.categoryName}} inside the for loop, on the line above the table.

5. List tags

An array from the input data can be used to dynamically generate an ordered or unordered list. In the following example:
  • items is an array that can be rendered as a dynamic list.
  • id, name, quantity, price, amount are the variables within the array that can be rendered as a repetitive field in the list.
The input data can be used to generate different types of lists:

Formatting lists

Box Doc Gen templates support a wide range of custom codes that you can use in the document template. Taking the following JSON input data as an example, you can introduce different separators and delimiters.

6. Conditions

You can use conditions to add input to the output document. The Box Doc Gen Template Creator add-in can help you define these conditions within the document template.

Supported conditions and operators

Tag typeConditions supportedOperators supported to chain conditions
String==(is equal to), !=(is not equal to), isPresentAND, OR
DateisPresentAND, OR
Number<, >, ==, !=, >=, <=AND, OR
The following JSON serves as input for defining conditions for the Box Doc Gen template.

Conditions with tables

Doc Gen enables you to conditionally render any content including tables, images, and so on. {{ if invoice.customerId isPresent }}
IdNameQtyPrice
{{tablerow item in invoice.items}}
{{item.id}}{{item.name}}{{item.quantity}}{{item.price}}
{{endtablerow}}
{{ endif }}

Conditions inside tables

Doc Gen enables you to conditionally render content with a column in a table. Examples
IdNameQtyPrice
{{ tablerow item in invoice.items }}
{{ item.id}}{{ item.name}}{{ item.quantity}}{{ if item.price isPresent}}{{item.price}}{{ else }}-{{ endif }}
{{ endtablerow }}

Skip table rows based on conditions

When you generate documents from arrays of data, such as invoices, statements, or packing lists, you often need to include only the rows that meet certain business rules. For example, you might want to hide line items that are out of stock, below a threshold, or flagged in a particular way. Use the skip-row-if modifier to attach a condition to a table row template. When Box Doc Gen generates the document, it evaluates each item in the source array against the condition:
  • If the condition is true, Box Doc Gen discards the entire row, and the row doesn’t display in the output.
  • If the condition is false, the row renders as usual.
This is a row-level operation. Even though you add the modifier to a single field, it removes the whole row: every column in that row is dropped, not only the field that has the modifier. The following JSON serves as input for the examples:
Example 1: Skip rows based on a single condition The following template skips every item with the type Fragile.
Item idDateQuantityAmount
{{ tablerow item in invoice.items }}
{{ item.id}}{{ item.date}}{{ item.quantity}}{{item.amount::skip-row-if(item.type == “Fragile”)}}
{{ endtablerow }}
The output table omits items 2 and 4: Example 2: Skip rows based on multiple conditions You can chain conditions with the AND and OR operators. The following template skips items with the type Fragile and a quantity of 50 or less.
Item idDateQuantityAmount
{{ tablerow item in invoice.items }}
{{ item.id}}{{ item.date}}{{ item.quantity}}{{item.amount::skip-row-if(item.type == “Fragile” AND item.quantity <= “50”)}}
{{ endtablerow }}
The output table omits only item 2. Item 4 is also Fragile, but its quantity is greater than 50, so it renders:

7. Calculations

Box Doc Gen templates support dynamic calculations. You can either write the computation code to the tagging language manually, or use the Box Doc Gen Template Creator add-in. Sample code calculations include:
  • Invoice: Determining the net invoice amount from individual line items. Example: Sum (Individual Line item amounts in the invoice)
  • Purchase order: Capping the maximum sourcing amount. Example: 5% * Net Order Value
  • Sales contracts: Defining penalty on SLA breach. Example: 10% * Total Sales Value
Supported operations The following JSON serves as input for adding calculations to the document template.
Examples:

8. Box Sign template tags

Box Sign template tags can be added to the Box Doc Gen template for the output document created via Box Doc Gen to be sent for e-signature. The table below lists the tags available in the Box Doc Gen Template Creator add-in and the tagging script.
Last modified on October 26, 2026