Barcodes are everywhere — on product packaging, shipping labels, event tickets, boarding passes, and inventory systems. If you're building an e-commerce platform, a warehouse management tool, or any kind of logistics application, you'll eventually need to generate (and maybe scan) barcodes programmatically.

In this guide, we'll cover what barcode types exist, when to use each, and how to generate them at scale using a barcode API — no dependencies, no ImageMagick, no server-side libraries required.

Barcode Formats: Which One Do You Need?

Not all barcodes are created equal. Each format was designed for a specific use case, and choosing the wrong one can cause real problems downstream.

1D Barcodes (Linear)

2D Barcodes

Generating Barcodes via API

The traditional approach — running a server-side library like ZXing (Java), python-barcode, or barcode.js — works, but adds complexity to your stack. You need to manage rendering, output formats, font rendering, and image encoding yourself.

A barcode API handles all of that for you. Send a request with the data and format, get back a clean image. That's it.

Here's how it works with the ToolCenter Barcode API:

GET https://api.toolcenter.dev/v1/barcode
  ?data=1234567890128
  &format=ean13
  &width=300
  &height=150

Returns a PNG (or SVG) barcode image ready to embed, download, or send to a printer.

Node.js Example

const toolcenter = require('toolcenter');
const tc = new toolcenter('YOUR_API_KEY');

const barcode = await tc.barcode({
  data: '1234567890128',
  format: 'ean13',
  width: 300,
  height: 150,
  outputFormat: 'png'
});

// barcode.url — hosted image URL
// barcode.base64 — base64-encoded image

Python Example

from toolcenter import ToolCenter

tc = ToolCenter("YOUR_API_KEY")

barcode = tc.barcode(
    data="1234567890128",
    format="ean13",
    width=300,
    height=150
)

print(barcode["url"])  # Use directly in your app

Common Use Cases

E-commerce: Product Labels

When a seller uploads a new product to your platform, auto-generate an EAN or UPC barcode and attach it to the product record. You can then render it on pick-pack slips, product pages, or PDF labels.

// On product creation
const label = await tc.barcode({
  data: product.gtin,
  format: 'ean13',
  width: 400,
  height: 180
});

await db.products.update(product.id, {
  barcode_url: label.url
});

Shipping: Carrier Labels

Most carrier label systems (FedEx, UPS, DHL) rely on Code 128 barcodes to encode tracking numbers. If you're generating custom shipping labels (e.g., for a 3PL or internal logistics system), use Code 128:

const shippingBarcode = await tc.barcode({
  data: shipment.trackingNumber,
  format: 'code128',
  width: 500,
  height: 100,
  includeText: true
});

Event Ticketing

For event tickets, QR codes are more common today (scannable on phone screens), but PDF417 is the standard for printed boarding passes and legal documents because it stores more data and is harder to counterfeit.

const ticket = await tc.barcode({
  data: JSON.stringify({
    eventId: 'EVT-20261201',
    attendeeId: 'ATT-99182',
    seat: 'B-14'
  }),
  format: 'pdf417',
  width: 400,
  height: 150
});

Inventory Management

For internal inventory, Code 39 or Code 128 are both fine. Use whichever your scanners support. Generate a barcode per SKU and print it on bin labels:

const skus = await db.inventory.findAll({ where: { barcodeUrl: null } });

for (const sku of skus) {
  const result = await tc.barcode({
    data: sku.code,
    format: 'code128',
    width: 350,
    height: 120,
    includeText: true
  });

  await sku.update({ barcodeUrl: result.url });
}

Output Format: PNG vs SVG

The API supports both raster (PNG) and vector (SVG) output:

// SVG for web display
const barcode = await tc.barcode({
  data: 'PRODUCT-SKU-001',
  format: 'code128',
  outputFormat: 'svg'
});

// Embed directly in HTML
res.send(`<img src="${barcode.url}" alt="Product barcode" />`);

Barcode Validation

EAN-13 and UPC-A use a check digit as the last digit. If the check digit doesn't match, scanners will reject the barcode. The API validates this automatically and returns an error if the data is invalid — saving you from printing thousands of unreadable labels.

{
  "error": "invalid_data",
  "message": "EAN-13 check digit mismatch. Expected 8, got 2.",
  "hint": "Use data '1234567890128' instead of '1234567890122'"
}

Batch Generation

Need to generate hundreds of barcodes at once? Use the Bulk API endpoint:

const barcodes = await tc.bulk([
  { api: 'barcode', data: '111122223333', format: 'ean13' },
  { api: 'barcode', data: '444455556666', format: 'ean13' },
  { api: 'barcode', data: 'SHIP-20261201-001', format: 'code128' },
  // ... up to 100 items per request
]);

barcodes.results.forEach((b, i) => {
  console.log(`Item ${i}: ${b.url}`);
});

Embedding Barcodes in PDFs

A common pattern is generating a barcode and then embedding it in a PDF label or invoice. You can combine the Barcode API with the HTML-to-PDF API in a single pipeline:

// 1. Generate barcode
const barcode = await tc.barcode({
  data: order.id,
  format: 'code128',
  width: 400,
  height: 100
});

// 2. Build label HTML with barcode embedded
const html = `
  <div style="font-family: monospace; padding: 20px;">
    <h2>Order #${order.id}</h2>
    <img src="${barcode.url}" style="width: 300px;" />
    <p>Ship to: ${order.shippingAddress}</p>
  </div>
`;

// 3. Convert to PDF
const pdf = await tc.pdf({ html, format: 'A6' });

// 4. Send to printer or store in S3
await uploadToS3(pdf.buffer, `labels/${order.id}.pdf`);

Pricing and Limits

Barcode generation is one of the cheapest API operations — it's CPU-light compared to screenshot rendering or PDF generation. On ToolCenter, barcode requests count as a single API call. You can generate thousands of barcodes per month on even the entry-level plan.

Check the pricing page for current plan limits.

Getting Started

  1. Sign up at toolcenter.dev
  2. Grab your API key from the dashboard
  3. Install the SDK: npm install toolcenter or pip install toolcenter
  4. Generate your first barcode in under 60 seconds

No infrastructure to manage, no font issues, no ImageMagick version mismatches. Just clean barcodes, on demand.