
Barcode Generator API
Utilities
Create scannable barcodes in Code 128, EAN-13, UPC-A, Code 39, ITF-14 and more, with check digits added for you. Download SVG or PNG, or copy the image.
Authentication
All API requests require a valid API key passed in the Authorization header as a Bearer token.
Rate Limit
20 requests per minute
Endpoints
1 endpoint available
Overview
Draw a barcode in one of 12 symbologies. The value is checked for the symbology you pick, and check digits are added where the symbology has one (EAN-13 from 12 digits, for example).
Symbologies
- Retail:
EAN13,UPC(UPC-A),EAN8,UPCE - General purpose:
CODE128(default),CODE39,CODE93 - Shipping:
ITF14,ITF - Specialist:
codabar,MSI,pharmacode
Output formats
png(default): the response body is the PNG file (Content-Type: image/png).svg: the response body is the SVG file (Content-Type: image/svg+xml).base64: JSON with the PNG as a data URL inimage, andtext, the full value that was encoded including any check digit.
Notes
widthis the bar width in pixels,heightthe bar height, andmarginthe blank border.scale(1 to 4) multiplies all sizes. An image can be at most 8000 pixels on a side.- The human-readable text under the bars is set in a monospace font. In SVG output the viewer picks the font;
in PNG output the server's font is used. Set
displayValueto false for bars only. - Colours are hex only. Set
transparentto true for no background. Scanners read dark bars on a light background best. - If the value is not valid for the symbology the API returns 400 and says what the symbology accepts.
Endpoints
POST
https://opentools.ca/api/v1/tools/barcode-generatorGenerate a barcode image
Request Body
Content-Type: application/json
| Parameter | Type | Required | Description |
|---|---|---|---|
| value | string | Required | The value to encode, 1 to 200 characters. What is valid depends on the symbology. |
| symbology | string Enum: EAN13, UPC, EAN8, UPCE, CODE128, CODE39, CODE93, ITF14, ITF, codabar, MSI, pharmacode | Optional | Barcode type.Default: CODE128 |
| format | string Enum: png, svg, base64 | Optional | png and svg return the image file; base64 returns JSON with a PNG data URL.Default: png |
| width | number | Optional | Width of the thinnest bar in pixels, 1 to 10.Default: 2 |
| height | number | Optional | Bar height in pixels, 20 to 500.Default: 100 |
| displayValue | boolean | Optional | Show the value as text under the bars.Default: true |
| fontSize | number | Optional | Text size in pixels, 8 to 60.Default: 20 |
| margin | number | Optional | Blank border (quiet zone) in pixels, 0 to 100.Default: 10 |
| lineColor | string | Optional | Bar and text colour, as hex.Default: #000000 |
| background | string | Optional | Background colour, as hex.Default: #ffffff |
| transparent | boolean | Optional | No background. Overrides background.Default: false |
| scale | number | Optional | Multiplies width, height, font size and margin, 1 to 4.Default: 1 |
Response Example
With format "png" or "svg" the body is the image file itself. With format "base64":
{
"success": true,
"symbology": "EAN13",
"text": "5901234123457",
"width": 234,
"height": 142,
"format": "base64",
"mimeType": "image/png",
"image": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
}Error Codes
400
Bad Request - Value not valid for the symbology, invalid option, or an image over 8000 pixels on a side401
Unauthorized - Invalid or missing API key403
Forbidden - API key inactive, expired, or request from a disallowed IP429
Too Many Requests - Rate limit exceeded500
Internal Server ErrorCode Examples
# Save a PNG
curl -X POST https://opentools.ca/api/v1/tools/barcode-generator \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"symbology": "EAN13", "value": "590123412345", "scale": 2}' \
-o barcode.png
# SVG
curl -X POST https://opentools.ca/api/v1/tools/barcode-generator \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"value": "OpenTools-2026", "format": "svg"}' \
-o barcode.svgRather use it in your browser? Open the Barcode Generator