Skip to content

Generate Barcode Label PDFs from CSV Data

Convert names, text SKUs and copy counts from CSV into JSON, then generate and check a batch label PDF.

Gookit Team About 3 min read

Turn a CSV of product names, SKUs and copy counts into a label PDF in two steps: convert the file to the API’s JSON structure, then submit it against a saved template. This workflow sends JSON to Gookit; it is not a direct CSV-upload endpoint.

The sample file contains two products and requests three labels:

products.csv
name,sku,quantity
Trail Bottle,TB-1042,2
Desk Tray,DT-2006,1

Prepare the files

Before converting your file, prepare:

  • A developer account and API key, with available output allowance. Check the current plans before submitting.
  • The saved 50 × 30 mm name/SKU template. Follow step 1 of the JSON batch tutorial and keep the returned template ID. Use the same developer account for the template and API key.
  • Python 3.10 or newer. The converter and PDF client use Python’s standard library, so this example needs no Python package installation.

The template binds name and sku. Adding a price column to the CSV alone will not add a price to the PDF: update the mapper and template if you want to print another field.

Keep identifiers as text

Format SKU columns as text before entering or importing values into a spreadsheet. The converter preserves 0001042 if those characters are present in the CSV. It cannot recover leading zeros that a spreadsheet already removed.

Use UTF-8 CSV with a header row. Quoted names containing commas work through Python’s CSV parser; splitting each line on a comma would break them. The converter accepts a UTF-8 byte-order mark, trims surrounding field whitespace and rejects blank names, blank SKUs, fractional quantities and zero quantities.

Convert and inspect before submitting

Run this in a new folder containing the downloaded files:

Terminal window
export TEMPLATE_ID="YOUR_SAVED_TEMPLATE_ID"
python3 csv-to-batch.py products.csv "$TEMPLATE_ID" > batch.json

If conversion reports an error, stop and fix that row. Do not submit a partially written output file. On success, inspect batch.json: it should have two items with quantities 2 and 1, and the total should be three.

The converter rejects batches above 1,000 labels. For a larger export, deliberately split the source into smaller files and keep a record of which parts were submitted. Splitting does not bypass per-key rate limits.

Generate the PDF once

Set your independent developer key locally, then submit:

Terminal window
export GOOKIT_API_KEY="YOUR_DEVELOPER_API_KEY"
python3 labels.py submit batch.json csv-labels.pdf

The script saves csv-labels.pdf.job.json after acceptance, checks the same job, and downloads the PDF without sending your API key to the storage host. If status checking or download stops, use:

Terminal window
python3 labels.py resume csv-labels.pdf.job.json csv-labels.pdf

If the submission itself timed out and no job ID was saved, investigate before another POST. Running the submit command twice creates two requests; a filename does not make a request idempotent.

Check the exported labels

With the 50 × 30 mm ROLL template, the example should produce three pages: Trail Bottle, Trail Bottle, Desk Tray. Check their visible names and scan the digital barcode values before testing your own stock at Actual Size.

Compare your file with this reference PDF, generated through the JSON batch API on September 20, 2026 using the same two products and copy counts:

50 by 30 mm Trail Bottle label with a Code 128 barcode encoding TB-1042

Trail Bottle 2 copies

50 by 30 mm Desk Tray label with a Code 128 barcode encoding DT-2006

Desk Tray 1 copy

Sample output generated through Gookit Label API. Three pages, one label per page.

Download the three-label PDF ↓

For the next batch, reuse the saved template and replace the CSV records. Keep the old input file with your own internal print record when repeatability matters; decide whether a later reprint should use the original values or current product data.

Try the sample with your account

Create a Gookit developer account, then use the JSON batch tutorial to prepare your key and template. Run the two-row CSV before replacing it with your inventory export. See Gookit Label API for supported output and access options.