How to generate a barcode (EAN-13, UPC-A, Code 128) with an API

Updated 2026-11-10

Use when an agent must produce a Code 128, Code 39, EAN, UPC-A or ISBN barcode image. Add output=url for a 24 h link.

From an MCP client, add https://tanod.dev/mcp and call make_barcode; its free daily calls are applied automatically, no key or signup.

POST the value and symbology to /v1/barcode. It returns a 1-D barcode image as SVG text (default) or a base64 PNG.

Request

data is required. type is code128 (default), code39, ean13, ean8, upca or isbn13. format is svg or png. text toggles the human-readable line under the bars. Code 128 takes 1 to 80 printable ASCII characters; EAN-13, EAN-8, UPC-A and ISBN-13 take the number without or with its check digit.

curl, using the free tier
curl -s -X POST https://tanod.dev/v1/barcode \
  -H 'X-Tanod-Free: 1' -H 'content-type: application/json' \
  -d '{"data": "96385074", "type": "ean8", "format": "png", "text": false}'

The file comes back as base64 in the JSON. To save it, pipe the response through jq and base64:

save the result to a file
curl -s -X POST https://tanod.dev/v1/barcode \
  -H 'X-Tanod-Free: 1' -H 'content-type: application/json' \
  -d '{"data": "96385074", "type": "ean8", "format": "png", "text": false}' \
  | jq -r '.data_base64' | base64 -d > barcode.png

Response

Response (example from the API spec, trimmed)
{
  "format": "png",
  "content_type": "image/png",
  "type": "ean8",
  "encoded": "96385074",
  "text": false,
  "bytes": 816,
  "width_px": 414,
  "height_px": 200,
  "data_base64": "iVBORw0KGgoAAAANSUhEUgAAAZ4AAADICAIAAABXvhAGAAAC90lEQVR4nO3bwWrD…",
  "source": {
    "library": "python-barcode 0.16.1",
    "license": "MIT",
    "url": "https://github.com/WhyNotHugo/python-barcode"
  }
}

Checked with an independent decoder

A barcode that scans as the wrong product is worse than one that does not scan, and a reader written from the same tables as the encoder will not catch it. So on 16 October 2026 we decoded one output of every symbology with ZXing-C++ 3.1.1, a decoder that shares no code with ours. All seven read back exactly as encoded: Code 128 Tanod 2026-10-16, Code 39 TANOD-123, EAN-13 4006381333931, EAN-8 96385074, UPC-A 036000291452 (ZXing reports it as the equivalent EAN-13 0036000291452), ISBN-13 9780306406157, and a QR code holding this page's URL. The same day, a wrong EAN-13 check digit (4006381333932) came back as a 422 invalid_checksum naming the right digit, 1. One decode per symbology is only a spot check; still test printed labels with a real scanner.

Checked on every call. Each output is decoded again with ZXing-C++ before it is returned: the answer carries verified: true and decoded_text. A symbol that does not decode to the value you asked for is a 500 verify_failed and is not charged. SVG output is verified through a PNG render of the same symbol. The price is unchanged. The same check runs on POST /v1/qr. To find the product behind a number, see the barcode product lookup API.

Limits and caveats

Check digits are enforced. If you supply a check digit for EAN-13, EAN-8, UPC-A or ISBN-13 and it is wrong, the call is a 422 invalid_checksum and is not charged; a different number is never silently encoded.

Retail use. Barcodes for products sold through retailers need numbers assigned by GS1 or your ISBN agency. This tool encodes a number; it does not assign one. Test a printed code with a real scanner.

For two-dimensional codes use the QR code guide.

Download link. Add "output": "url" to the request and the file is stored for 24 hours and returned as a link (url, expires_at, sha256) instead of base64, which keeps it out of your context window. The price is the same. How the links work.

Price and free allowance

USD 0.001 per call, paid in USDC on Base, Polygon, Solana, BNB Chain or Arbitrum with x402. 10 free calls per IP per UTC day with the header X-Tanod-Free: 1. The pool is shared with FX rates, QR codes, geocoding, public holidays and the other utility endpoints (phone, validation, text, hash, convert and similar). MCP tool: make_barcode at https://tanod.dev/mcp, where the free tier is automatic.

All endpoints →

Use it from Claude without writing code: in claude.ai or Claude Desktop, add https://tanod.dev/mcp/util?via=barcode-generator-api as a custom connector (steps), then ask in plain words, for example "Make a Code 128 barcode for the order number 100234." The free daily allowance is applied automatically over MCP. Beyond it a call needs an x402 payment, which these clients can make.

Related guides: why a barcode can scan as a different product, What QR code and barcode APIs cost (price data), How to generate a QR code via API, How to validate an IBAN or BIC with an API, How to resize an image from a URL with an API. Back to tanod.dev or the guide index. Results are automated and heuristic.