# Barcode Generator: EAN, UPC, Code 128 and more to PNG and SVG (`examsens.ai/barcode-generator`) Actor

Generates EAN-13, EAN-8, UPC-A, ISBN, ITF, ITF-14, Code 128, Code 39, Data Matrix and PDF417 barcodes as PNG and SVG in bulk. Computes or validates check digits, prints retail style digits, and scans every image back to prove it reads.

- **URL**: https://apify.com/examsens.ai/barcode-generator.md
- **Developed by:** [Ed Rayyis](https://apify.com/examsens.ai) (community)
- **Categories:** Developer tools, E-commerce
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.70 / 1,000 barcode generateds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Barcode Generator: EAN, UPC, Code 128 and more to PNG and SVG

Generate barcodes in bulk as PNG and SVG files. Every value is checked before it is drawn, check digits are added or verified, and every image is scanned back after it is made to confirm it reads.

### Types

| Type | Takes | Check digit |
| --- | --- | --- |
| EAN-13 | 12 digits, or 13 with the check digit | Added or verified |
| EAN-8 | 7 digits, or 8 | Added or verified |
| UPC-A | 11 digits, or 12 | Added or verified |
| ISBN | ISBN-10 or ISBN-13, hyphens allowed. Drawn as the EAN-13 Bookland barcode. | ISBN-10 check verified, EAN check added |
| ITF (Interleaved 2 of 5) | An even number of digits | n/a |
| ITF-14 | 13 digits, or 14 | Added or verified |
| Code 128 | Any ASCII text | Built into the symbol |
| Code 39 | 0 to 9, A to Z, space and `- . $ / + %`. Small letters become capitals unless you turn that off. | Optional mod 43 character |
| Data Matrix | Any text, including accented letters and symbols | Built into the symbol |
| PDF417 | Any text. Error correction level 0 to 8. | Built into the symbol |

A wrong check digit is reported with the right one, for example `check digit is wrong: 8 given, 7 expected (5901234123457)`, and no image is made for it.

### Look

- PNG, SVG or both. The SVG draws the bars as one vector path, so it prints sharp at any size.
- Module width in pixels (default 3) and bar height in pixels (default 50 module widths)
- Quiet zone in module widths (default 10 on linear codes, 2 on Data Matrix and PDF417)
- Human readable text under linear codes, on by default. EAN-13, EAN-8 and UPC-A get the retail layout: the guard bars run down between the digit groups, and the first (and for UPC-A the last) digit sits outside the bars. You can print your own line of text in place of the value.
- Bar and background colors in hex, or a transparent background
- PNG resolution stored in the file (default 300 DPI), so print software sizes it right
- Data Matrix as square symbols (default) or square or rectangular

### Input

- Values: one barcode per value, all of the chosen type
- Mixed items: a JSON list for different types in one run, such as `[{"value": "SKU-778-A", "type": "code39"}, {"value": "Batch 2026-10", "type": "datamatrix", "fileName": "batch-label"}]`. Each item may also set `text`, the line printed under the bars.
- The look and symbology options above

### Output

The images go to the run's key value store. The dataset holds one item per value with `index`, `value`, `type`, `typeName`, `ok`, `encodedValue` (with the check digit), `checkDigit`, `checkDigitStatus` (`added` or `valid`), `isbn10` for ISBN-10 input, `width`, `height`, `verified` and `decodedValue` (what the scan of the finished image read), `pngUrl` and `svgUrl`.

A value that cannot be encoded gets `ok: false` and an `error`, for example an odd number of digits for ITF, `Code 39 cannot hold 'É'`, or `Code 128 takes ASCII characters only`. The other values still run.

### Pricing

Pay per event: one event per barcode generated, with PNG and SVG together counting once. A value that fails is not charged. The run stops when it reaches the maximum charge you set.

### Scope and conduct

Everything runs inside the actor. No value is sent anywhere.

### Support

Questions and problems: the Issues tab on this page. Replies are written by an AI assistant on behalf of the developer and reviewed by the developer.

# Actor input Schema

## `values` (type: `array`):

One barcode per value, all of the type below. EAN, UPC, ITF-14 and ISBN values work with or without the check digit.

## `type` (type: `string`):

Type for the values above, and for items that do not name one.

## `items` (type: `array`):

Barcodes of different types in one run: objects with "value", and optional "type", "fileName" and "text" (the line printed under the bars).

## `outputFormats` (type: `array`):

PNG, SVG or both.

## `moduleWidth` (type: `integer`):

Width of the narrowest bar, or the side of one 2D module.

## `barHeight` (type: `integer`):

Height of the bars of linear barcodes. Leave empty for 50 module widths.

## `quietZone` (type: `integer`):

Blank margin around the code, in module widths. Leave empty for 10 on linear codes (at least 9 on EAN-13 and UPC-A, to fit the outside digit), 2 on Data Matrix and PDF417.

## `showText` (type: `boolean`):

Human readable text under linear barcodes. EAN and UPC digits are grouped the retail way.

## `foreground` (type: `string`):

Hex color of the bars and text.

## `background` (type: `string`):

Hex color of the background, or transparent.

## `dpi` (type: `integer`):

Resolution stored in the PNG file, used by print software to size the image.

## `code39Uppercase` (type: `boolean`):

Code 39 holds capital letters only. When on, small letters are turned to capitals; when off, they are an error.

## `code39CheckDigit` (type: `boolean`):

Append the optional modulo 43 check character.

## `dataMatrixShape` (type: `string`):

Square symbols, or let short values use a smaller rectangular symbol.

## `pdf417EcLevel` (type: `string`):

0 to 8. Higher levels survive more damage and make a larger symbol. Leave empty for the default.

## Actor input object example

```json
{
  "values": [
    "590123412345",
    "4006381333931",
    "ORDER-10045"
  ],
  "type": "ean13",
  "items": [
    {
      "value": "SKU-778-A",
      "type": "code39"
    },
    {
      "value": "Batch 2026-10 line 4",
      "type": "datamatrix"
    }
  ],
  "outputFormats": [
    "png",
    "svg"
  ],
  "moduleWidth": 3,
  "showText": true,
  "foreground": "#000000",
  "background": "#FFFFFF",
  "dpi": 300,
  "code39Uppercase": true,
  "code39CheckDigit": false,
  "dataMatrixShape": "square"
}
```

# Actor output Schema

## `results` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "values": [
        "590123412345",
        "4006381333931",
        "ORDER-10045"
    ],
    "items": [
        {
            "value": "SKU-778-A",
            "type": "code39"
        },
        {
            "value": "Batch 2026-10 line 4",
            "type": "datamatrix"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("examsens.ai/barcode-generator").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "values": [
        "590123412345",
        "4006381333931",
        "ORDER-10045",
    ],
    "items": [
        {
            "value": "SKU-778-A",
            "type": "code39",
        },
        {
            "value": "Batch 2026-10 line 4",
            "type": "datamatrix",
        },
    ],
}

# Run the Actor and wait for it to finish
run = client.actor("examsens.ai/barcode-generator").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "values": [
    "590123412345",
    "4006381333931",
    "ORDER-10045"
  ],
  "items": [
    {
      "value": "SKU-778-A",
      "type": "code39"
    },
    {
      "value": "Batch 2026-10 line 4",
      "type": "datamatrix"
    }
  ]
}' |
apify call examsens.ai/barcode-generator --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,examsens.ai/barcode-generator"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/5WHtl6r7d2Jxc5d3n/builds/bhurD7Yp8EMoQgFy9/openapi.json
