Code 128 Barcode Generator API
High-density alphanumeric barcode for logistics
Sample Code 128 barcode
Generated live by the BarGen API from BARGEN-12345
Code 128 is a high-density linear symbology defined by ISO/IEC 15417 that encodes the full 128-character ASCII set, including letters, digits, punctuation, and control characters. It uses three character subsets (A, B, and C) that a scanner can switch between mid-symbol, letting Code 128 pack numeric-heavy data almost twice as densely as alphanumeric data. A mandatory checksum character detects most scanning errors, which makes it dependable for automated logistics and manufacturing lines.
BarGen builds Code 128 symbols on request: pass any ASCII string with format set to code128 and choose SVG for scalable, print-ready artwork or PNG for quick previews and web thumbnails. The API automatically selects the most efficient subset combination and appends the checksum, so no manual encoding logic is required on the client side.
Code 128 is a high-density linear barcode symbology defined in ISO/IEC 15417:2007. It is used extensively in logistics and transportation industries for ordering, distribution, and supply chain management.
The symbology can encode all 128 ASCII characters, making it highly versatile. It uses three different character sets (A, B, and C) to optimize the barcode length depending on the data being encoded. Character set C is particularly efficient for encoding numeric data.
Code 128 includes a mandatory check digit for data integrity verification. The barcode automatically calculates this check digit, ensuring that scanning errors are detected. This makes it one of the most reliable 1D barcode formats available.
It is commonly used in shipping labels, inventory management, product identification, and anywhere alphanumeric data needs to be encoded in a compact format.
Common use cases
Warehouse and inventory management
Code 128 is the default symbology for internal SKU and location labels because it packs long alphanumeric identifiers into a compact, reliably scannable code.
Shipping and logistics labels
Carriers and 3PL providers print Code 128 on package labels for tracking numbers, since its density suits long numeric strings without needing extra label space.
Access badges and asset tags
Corporate ID badges and IT asset tags commonly use Code 128 to encode employee or asset numbers because most handheld and fixed scanners decode it without configuration changes.
Generate Code 128 via the REST API
curl "https://api.bargen.pro/v1/barcode/code128?data=BARGEN-12345&format=svg" \
-H "X-API-Key: YOUR_API_KEY"
Returns the barcode as SVG. See the API documentation for all options.
Frequently asked questions
What is the maximum length for a Code 128 barcode?
There is no fixed limit in the specification, but practical scanner performance and label width usually cap useful payloads around 40 to 50 characters. Longer strings work but produce wider symbols that are harder to scan reliably at a distance.
How is Code 128 different from Code 39?
Code 128 encodes the full ASCII character set at roughly twice the density of Code 39 and includes a mandatory checksum, while Code 39 supports a smaller character set and an optional checksum. Code 128 is generally preferred where label space is limited.
Do I need to calculate the checksum myself?
No. BarGen calculates and appends the Code 128 checksum character automatically based on the input data, so you only need to supply the raw string you want encoded.
Start generating Code 128 barcodes
Free tier with 1,000 API calls per month. No credit card required.