---
source: https://carbone.io/examples/nutrition-facts-label/
title: "Food Label Software: FDA Nutrition Facts Labels | Carbone"
description: "Add a nutrition label generator to your food label software: an SVG template turns recipe data into FDA Nutrition Facts panels and a rounding audit."
generated_at: "2026-11-17"
---

# Nutrition Facts label

FDA Nutrition Facts panels from your recipe and PLM data

[![Nutrition Facts label: PDF generated from an SVG template and JSON data](/examples/nutrition-facts-label/thumb-result.webp)](/examples/nutrition-facts-label/result.pdf "Download the generated document")

[Download template](/examples/nutrition-facts-label/template.svg)

[Sample data](/examples/nutrition-facts-label/data.json)

[Download the generated PDF](/examples/nutrition-facts-label/result.pdf)

- **Template:** SVG
- **Export as:** PDF, PNG, SVG, WebP [+24 more](/documentation/developer/http-api/generate-reports.md#output-file-type)
- **Carbone:** 5.18+

Features

-   [SVG](/documentation/design/template-formats/svg.md)
-   [Loop](/documentation/design/repetitions/with-arrays.md)
-   [Nested loop](/documentation/design/repetitions/with-arrays.md)
-   [Condition](/documentation/design/conditions/overview.md)
-   [Number format](/documentation/design/formatters/number.md)
-   [Date format](/documentation/design/formatters/date.md)
-   Batch

## Generate Nutrition Facts labels from your PLM

Every packaged food sold in the United States carries a Nutrition Facts label, laid out by [21 CFR 101.9](https://www.ecfr.gov/current/title-21/chapter-I/subchapter-B/part-101/subpart-A/section-101.9) as revised in 2016. Food manufacturers keep their formulas and nutrient analyses in a PLM or recipe system, which applies the FDA rounding rules and computes the % Daily Values. For each new product or formula revision, the system sends the declared values to the Carbone API as JSON, and an SVG template returns a label proof: the panel at actual size for the packaging artwork, the ingredient and allergen statements, and a rounding audit for the regulatory review. In this example, Northfold Foods, a fictional food manufacturer, prints the proofs of a pint of ice cream, a granola and a protein bar.

In this example, you will:

-   Print one proof per product, one PDF page each
-   Switch between the standard vertical panel and the dual column panel
-   Add the voluntary sugar alcohol line only when the product declares it
-   Size the label box to the number of lines
-   List the rounding audit with a nested loop

## Panel layout

The panel follows paragraph (d) of the regulation and the graphic model of [Appendix B to Part 101](https://www.ecfr.gov/current/title-21/chapter-I/subchapter-B/part-101/appendix-Appendix%20B%20to%20Part%20101).

| Area | Content | Rule |
| --- | --- | --- |
| Heading | Nutrition Facts | Full width of the panel, larger than any other text except the calories amount |
| Servings | Servings per container, serving size | 10 pt, serving size in bold. Servings between 2 and 5 round to 0.5, with "About" when rounded |
| Calories | Calories per serving | "Calories" in 16 pt bold, the amount in 22 pt bold, between a 7 pt and a 3 pt bar |
| Nutrients | Fat, cholesterol, sodium, carbohydrate, sugars, protein | 8 pt, key nutrients in bold, sub-nutrients indented, hairlines between lines. Added sugars read "Includes 9g Added Sugars", under a shortened rule |
| Vitamins and minerals | Vitamin D, calcium, iron, potassium | 8 pt, amount and % DV, after a 7 pt bar |
| Footnote | The % Daily Value statement | 6 pt, after a bar |
| Box | Black on white | 0.5 pt box rule, 3 pt from the text |

A product whose container holds 200% to 300% of its reference amount shows two columns, per serving and per container, separated by vertical lines, as required by paragraph (b)(12)(i). The pint of ice cream holds three servings of 2/3 cup.

## How to generate Nutrition Facts labels from JSON

Follow these steps to build the label proof with Carbone:

### 1\. Set the page and the type

-   Set the page on the `svg` element: `width="8.5in" height="11in" viewBox="0 0 612 792"`. One unit is one point, so the sizes of the regulation go in as they are: 8 pt for the nutrients, 7 pt and 3 pt for the bars, 0.25 pt for the hairlines.
-   Set the font once, on the `svg` element: `font-family="Helvetica, Arial, Liberation Sans, sans-serif"`. Arial and Liberation Sans have the same widths as Helvetica, so the panel keeps its layout on every server. A class sets the bold nutrients in Arial Black, the heavy weight of the FDA model.
-   The heading "Nutrition Facts" is drawn as a path in Franklin Gothic Heavy, one of the two typefaces of Appendix B, stretched to the full width of the panel.
-   SVG text does not wrap. The ingredient statement and the audit table sit in a `foreignObject` element, where the text flows like in HTML. See [SVG templates](/documentation/design/template-formats/svg.md#best-practices).

### 2\. Repeat the proof for each product

Group all the elements of the page, and move each copy one page width to the right with the [loop index](/documentation/design/repetitions/with-arrays.md#access-the-loop-iterator-value):

```xml
<g id="proof" transform="translate({d.products[i].itemNo:print(.i):mul(612)} 0)">
```

A second group after it, with `{d.products[i+1].itemNo}`, closes the [loop](/documentation/design/template-formats/svg.md#loops). Carbone puts each product on its own page (step 6).

### 3\. Print the declared values

Your PLM applies the rounding rules of paragraph (c) and sends the declared values of each product in `perServing`, and in `perContainer` for a dual column product. The template adds the units:

```xml
<text x="3.5" y="101.46" font-size="8"><tspan class="k">Total Fat</tspan> {d.products[i].perServing.totalFat}g</text>
<text x="173.5" y="101.46" font-size="8" class="k" text-anchor="end">{d.products[i].perServing.totalFatDV}%</text>
```

-   The % Daily Value is right-aligned with `text-anchor="end"` on the right edge of the panel.
-   The added sugars line reads `Includes {d.products[i].perServing.addedSugars}g Added Sugars`, the wording of paragraph (c)(6)(iii).

### 4\. Choose the panel format

The template holds both panels. A [condition](/documentation/design/conditions/inline-conditions.md) shows one of them:

```xml
<g id="panel-standard" display="{d.products[i].dualColumn:ifEQ(true):show('none'):elseShow('inline')}">
<g id="panel-dual" display="{d.products[i].dualColumn:ifEQ(true):show('inline'):elseShow('none')}">
```

The dual column panel prints `{d.products[i].perContainer.calories}` next to `{d.products[i].perServing.calories}`, and "Incl. Added Sugars", the abbreviation that the regulation allows in dual column displays.

### 5\. Add the optional sugar alcohol line

The protein bar declares its sugar alcohol, the granola does not. The line shows only when the value exists:

```xml
<g display="{d.products[i].perServing.sugarAlcohol:ifEM():show('none'):elseShow('inline')}">
```

-   Every line below it sits in a group that moves down one line of 12 points: `transform="translate(0 {d.products[i].perServing.sugarAlcohol:ifEM():show(0):elseShow(12)})"`.
-   The height of the box follows with the same condition: `height="{d.products[i].perServing.sugarAlcohol:ifEM():show(294.98):elseShow(306.98)}"`.

### 6\. List the rounding audit

The audit shows, for each nutrient, the analyzed amount, the paragraph of 21 CFR 101.9, its rounding rule, and the value on the label. A [nested loop](/documentation/design/repetitions/with-arrays.md) repeats the table row for each item of `audit`:

```xml
<tr><td>{d.products[i].audit[i].nutrient}</td><td class="n">{d.products[i].audit[i].analyzed:formatN(2)} {d.products[i].audit[i].unit}</td> ... </tr>
<tr><td>{d.products[i].audit[i+1].nutrient}</td></tr>
```

[:formatN(2)](/documentation/design/formatters/number.md#formatn-precision-options) prints every analyzed amount with two decimals, and [:formatD](/documentation/design/formatters/date.md) prints the proof date as `Nov 12, 2026`.

### 7\. Print every proof in one request

Send the list of products with the [batch options](/documentation/developer/http-api/generate-reports.md#batch-processing):

```json
{
  "data": { "products": [ ... ] },
  "convertTo": "pdf",
  "converter": "C",
  "batchSplitBy": "d.products",
  "batchOutput": "pdf"
}
```

-   Carbone generates one proof for each product and merges them into one PDF, one Letter page per product.
-   A batch is an [asynchronous request](/documentation/developer/http-api/generate-reports.md#asynchronous-jobs): set the `carbone-webhook-url` header.
-   `"converter": "C"` draws the SVG with Chrome. The PDF keeps the panel as vector shapes, ready to place in the packaging artwork.

> ℹ️ **Note:** SVG templates require Carbone v5. The conversion of an SVG to PDF with Chrome requires Carbone v5.17.0 or later.

## Related Examples

- [EU energy label](/examples/eu-energy-label/index.md): SVG template to PDF.
- [GHS chemical label](/examples/ghs-chemical-label/index.md): HTML template to PDF.
- [GHS safety data sheet](/examples/safety-data-sheet/index.md): DOCX template to PDF.

## Related topics

- [DPE energy performance certificate](/examples/dpe-energy-performance-certificate/index.md)
- [EU energy label](/examples/eu-energy-label/index.md)
- [EU tyre label](/examples/eu-tyre-label/index.md)
- [CSRD sustainability statement](/examples/csrd-sustainability-report/index.md)
- [Prescription with medication schedule](/examples/prescription/index.md)
- [CMS-1500 claim form](/examples/cms-1500-claim-form/index.md)
