Code 128 Barcode Complete Guide

Code 128 is one of the most widely used linear barcodes in the world, and for good reason. It packs a lot of data into a compact space and handles everything from shipping labels to inventory tags without breaking a sweat.

If you need to encode alphanumeric data and want a format that scanners everywhere will recognize, Code 128 is almost always the right choice.

What Is Code 128?

Code 128 is a high-density, linear (1D) barcode symbology capable of encoding the full 128-character ASCII character set. Unlike some older formats that only handle uppercase letters or numbers, Code 128 can represent uppercase and lowercase letters, digits, and a range of special characters all within the same barcode.

It was introduced in 1981 and has since become a standard in logistics, manufacturing, retail, and healthcare. The format is governed by ISO/IEC 15417 and is supported by virtually every modern barcode scanner on the market.

One of its key technical features is its use of three internal subsets. Code 128A handles uppercase letters and control characters. Code 128B handles the full printable ASCII range including lowercase. Code 128C is optimized for pairs of digits, encoding two digits per symbol and making it extremely compact for numeric-only data. A single barcode can switch between subsets mid-stream, which is how the format stays efficient across varied content.

Every Code 128 barcode includes a check character calculated from the encoded data. This helps scanners catch read errors before they cause problems downstream.

Common Use Cases

Code 128 turns up in a lot of places because it handles real-world data well. Here are some of the contexts where it is most commonly used:

Code 128 vs Code 39: Which Should You Use?

Code 39 was one of the first alphanumeric barcodes and is still in active use, particularly in older industrial and government systems. But when you compare the two formats side by side, Code 128 has a clear edge in most modern scenarios.

Feature Code 128 Code 39
Character Set Full 128 ASCII (upper, lower, digits, symbols) 43 characters (A-Z uppercase, 0-9, a few symbols)
Density High, typically 25-30% more compact Lower density, longer barcodes for same data
Check Digit Mandatory, built into the standard Optional
Lowercase Letters Yes (Subset B) No
Numeric Efficiency Very high via Subset C (2 digits per symbol) Standard, one character per symbol

In short: if you are designing a new system or generating barcodes for shipping, healthcare, or anything that might include lowercase letters or special characters, Code 128 is the better choice. Code 39 is worth considering only when compatibility with legacy equipment is a hard requirement, since some older scanners or industrial readers may not handle Code 128 reliably. You can also generate Code 39 barcodes on this site if that format is what your system requires.

How to Generate a Code 128 Barcode Online

The Code 128 Barcode Generator on FJ TechTools is free and requires no account. Here is how to use it:

  1. Open the tool: Go to /barcode-generator/code128.
  2. Enter your data: Type or paste the text you want to encode. This can be a part number, serial number, tracking code, or any string of ASCII characters. Code 128 handles mixed alphanumeric content well, so you do not need to strip out letters or special characters first.
  3. Preview the barcode: The barcode renders in real time as you type. You can see the bars and the human-readable text below them.
  4. Adjust settings if needed: Options typically include bar width, height, and whether to display the text label. Adjust these to fit your label size or print specifications.
  5. Download: Save the barcode as a PNG or SVG file. SVG is usually the better choice for print since it scales without quality loss. PNG works well for digital use or when your system expects a raster image.

If you need to create a large batch of barcodes from a list of values, the Bulk Barcode Generator lets you generate multiple barcodes at once without doing them one at a time.

Generate a Code 128 Barcode Free

Understanding the Code 128 Format

A Code 128 barcode has a defined physical structure. From left to right, it contains a quiet zone (a blank margin), a start character that tells the scanner which subset is active, the encoded data characters, a check character, a stop character, and another quiet zone on the right. Each character is represented by three bars and three spaces, and the barcode always terminates with a four-bar stop pattern.

The check character is calculated by taking the value of the start character, then adding the weighted sum of every data character (each multiplied by its position index), and taking the result modulo 103. This is computed automatically by any compliant generator, so you do not need to work it out manually, but understanding it helps when troubleshooting scan errors or validating barcodes programmatically.

For barcodes where the check character matters and you want to verify or understand it, the Barcode Check Digit Calculator on this site can help.

Tips for Getting Good Scan Results

Generating a technically correct barcode is only half the job. How you print and apply it affects whether it scans reliably in the real world.

Code 128 and GS1-128

GS1-128 (previously known as UCC/EAN-128) is a specific application of the Code 128 format governed by GS1 standards. It uses a special Function 1 character at the start of the data to signal that what follows is structured GS1 data, organized with Application Identifiers (AIs) that define what each segment of data means, for example (01) for a GTIN, (17) for an expiration date, or (10) for a batch number.

If you are generating barcodes for supply chain use and your trading partner or retailer requires GS1-128 compliance, you need to follow GS1's formatting rules for the data string, not just pick Code 128 as the symbology. The barcode format itself is Code 128, but the data structure is what makes it GS1-128.

Frequently Asked Questions

What characters can Code 128 encode?

Code 128 can encode all 128 ASCII characters, including uppercase and lowercase letters, digits 0 through 9, punctuation, and control characters. This makes it far more flexible than older formats like Code 39, which is limited to uppercase letters, numbers, and a handful of symbols.

Is there a maximum length for Code 128 data?

There is no hard technical maximum defined in the Code 128 specification, but practical limits apply. The longer your data, the wider the barcode. Most barcode system implementations recommend keeping data to around 48 characters or fewer to ensure the barcode remains scannable at a reasonable physical size. Very long strings produce barcodes that are difficult to print and scan accurately.

Do I need to calculate a check digit for Code 128 myself?

No. Any compliant Code 128 generator, including the one on this site, calculates and appends the check character automatically. You just provide the data you want to encode. If you are validating an existing barcode or working with raw barcode data programmatically, the Barcode Check Digit Calculator can help you verify it.

What is the difference between Code 128A, 128B, and 128C?

These are the three subsets within the Code 128 format. Subset A supports uppercase letters, digits, and ASCII control characters. Subset B supports the full printable ASCII character set including lowercase. Subset C encodes pairs of digits (00 through 99) as single symbols, making it very compact for numeric-only data. A single barcode can switch between subsets mid-stream using special shift characters, which allows the encoder to optimize density automatically.

Can I use Code 128 for retail product barcodes?

Code 128 is not used for consumer-facing retail point-of-sale scanning, where EAN-13 and UPC-A are the standards. Those formats carry registered product identifiers that retailers and checkout systems expect. Code 128 is common on internal retail labels, shelf tags, and logistics barcodes, but if you are barcoding a product for sale in stores, you likely need an EAN-13 or UPC-A barcode instead. See our guide on EAN vs UPC to understand which applies to your situation.

How is Code 128 different from a QR code?

Code 128 is a one-dimensional (1D) barcode, meaning it encodes data in a single row of varying-width bars. A QR code is two-dimensional (2D) and encodes data in a grid pattern, which allows it to store significantly more information and be scanned from any angle. For most inventory and logistics uses, Code 128 is sufficient. If you need to encode a URL, a large block of text, or structured data in a compact square format, a QR code is worth considering instead.

What file format should I download my Code 128 barcode in?

SVG is the best choice for print because it is a vector format and scales to any size without losing sharpness. PNG is fine for digital use, email, or when the software you are working with does not accept SVG. Avoid using heavily compressed JPEGs for barcodes since compression artifacts can degrade bar edges and cause scan failures.

Generate Your Code 128 Barcode Free

Enter any text or alphanumeric string and download a print-ready barcode in seconds, no account required.

Open Code 128 Generator

Code 128 Barcode Complete Guide