What is a Code 128 barcode?
Code 128 is a linear (1D) barcode symbology that can encode the full 128-character ASCII set: uppercase and lowercase letters, digits, punctuation and control characters. It is one of the most widely used barcodes in logistics, healthcare, libraries, access control and asset management.
The symbology is specified in the international standard ISO/IEC 15417. Because it is so common, virtually every modern laser, LED and camera-based scanner reads it without special setup.
How a Code 128 barcode is built
- Quiet zone on the left.
- Start character, which also selects the first code set (A, B or C).
- Data characters, each made of three bars and three spaces across 11 modules.
- Check character, calculated from the data.
- Stop pattern, 13 modules wide.
- Quiet zone on the right.
Why people choose it
- Letters and numbers. Unlike EAN-13 or UPC-A, it handles IDs such as NWL-0428 or BK-2291-A.
- Compact. It is denser than older alphanumeric formats such as Code 39, so the same ID needs less space.
- Reliable. The check character and the strict pattern rules make misreads rare.
- No registration. You can use any values that suit your system.
A note on GS1-128
GS1-128 (formerly UCC/EAN-128) is a specific application of Code 128 used on shipping and logistics labels, with GS1 Application Identifiers that mark data such as batch numbers and dates. It follows extra GS1 rules. If a retailer or carrier asks for GS1-128, follow their label specification.
What are Code 128 code sets A, B and C?
Code 128 has three code sets that share the same bar patterns but assign them different characters. A barcode can switch between sets mid-way to encode data in the fewest characters.
Code set A
- Uppercase letters, digits and punctuation.
- ASCII control characters, such as tab and carriage return.
- No lowercase letters.
Code set B
- Uppercase and lowercase letters, digits and punctuation.
- The usual choice for general text and mixed IDs.
Code set C
- Pairs of digits from 00 to 99, each encoded as a single character.
- Halves the width of long numeric strings, which is why it is common for numeric shipping and tracking numbers.
Switching sets
Special characters let a barcode switch from one set to another, or shift for a single character. A scanner decodes all of this automatically and outputs only your original value, so the person scanning never sees which set was used.
What CardDeck accepts
The CardDeck Code 128 generator accepts printable characters (letters, digits, spaces and symbols) up to 40 characters per barcode. That covers employee numbers, asset tags, ticket codes and internal SKUs. Control characters are rarely needed on cards and labels and are not part of the input.
How is the Code 128 check character calculated?
The Code 128 check character is a modulo-103 checksum. You take the start character's value, add each data character's value multiplied by its position, divide the total by 103 and use the remainder as the check character's value.
Step by step
- Take the value of the start character (103 for start A, 104 for start B, 105 for start C).
- For each data character, multiply its value by its position: 1 for the first character, 2 for the second, and so on.
- Add the start value and all the products.
- Divide by 103. The remainder is the check value.
- Encode the character with that value just before the stop pattern.
Why it matters
If a scanner misreads one bar, the recalculated checksum will almost always not match, so the scanner rejects the read and tries again instead of sending a wrong value to your system.
You never type it
The check character is part of the bar pattern only. It is not printed in the human-readable text and not sent to your system by the scanner. CardDeck calculates it for every barcode, so you only enter your value. Unlike EAN-13 and UPC-A, Code 128 has no check digit to include in your data; see the EAN-13 barcode generator for how retail check digits differ.
What size should a Code 128 barcode be?
A Code 128 barcode's width depends on its content and its X-dimension, the width of the narrowest bar. Choose an X-dimension your printer and scanner handle well, keep at least 10X of quiet zone on each side and do not make the bars too short.
Working out the width
Every Code 128 barcode is 11 modules per character, plus 35 modules for the start character, check character and stop pattern. In code set B, an 8-character ID such as NWL-0428 is 11 × 8 + 35 = 123 modules wide.
- At an X-dimension of 0.25 mm, that is about 31 mm of bars.
- Add 2.5 mm of quiet zone on each side (10X) for about 36 mm in total.
- At 0.33 mm, the same barcode is about 41 mm of bars plus 3.3 mm on each side.
Long all-numeric values are narrower if the encoder uses code set C.
Height
Keep the bars tall enough to scan at a slight angle. A practical minimum is about 15% of the barcode's width, and taller is easier, especially for hand-held scanners. On an ID card, 8–12 mm of bar height is common.
Printing tips
- Black bars on a white background.
- SVG output, so edges stay sharp.
- On thermal printers, use an X-dimension that is a whole number of printer dots.
- Avoid red bars, which red-light laser scanners cannot see.
Where is Code 128 used?
Code 128 is used wherever a system needs to identify something with a short alphanumeric code: people, assets, tickets, documents and shipments. If the item is not sold at a retail checkout, Code 128 is usually the right choice.
Common uses
- Employee ID cards for door readers, time clocks and canteen tills. Add it to an employee ID card template.
- Student and library cards for borrowing and attendance.
- Asset tags on laptops, tools and equipment, matched to an asset register.
- Inventory and bin labels in stockrooms and warehouses.
- Tickets and wristbands for event check-in.
- Documents and files in offices, labs and clinics.
- Shipping references and internal order numbers.
Before you choose values
- Check which formats your scanner or software is set to accept. Most accept Code 128 by default.
- Use a consistent pattern, such as a prefix and a fixed-length number (AST-00412).
- Avoid characters that look alike in human-readable text, such as O and 0, if people will ever type the code.
- Keep values unique across your whole system.
How do I generate many Code 128 barcodes at once?
Upload a CSV or Excel file with one value per row to the bulk barcode generator, choose Code 128 and download a ZIP of files or a print-ready PDF sheet. The rows per job are 25 on Free, 500 on Pro, 2,000 on Team and 25,000 on Business.
Steps
- Put each value in its own row, with a header such as asset_id.
- Format the column as Text in Excel so leading zeros survive.
- Upload the file and choose Code 128.
- Review flagged rows: empty values, duplicates or unsupported characters.
- Download SVG or PNG files named from your values, or a PDF sheet.
The bulk barcode generator page covers label printing and how to place barcodes on cards in the same job. For other formats, start at the main barcode generator.
Tips for large ID registers
- Use a fixed-length number with a prefix, such as AST-00412, so every barcode is the same width and fits the same label.
- Keep IDs in one master sheet and generate from it every time, rather than retyping values.
- Split very large registers by site or department and run one job per file.
Code 128 vs other common barcode formats
| Without CardDeck | With CardDeck | |
|---|---|---|
| Characters | EAN-13 / UPC-A: digits only | Code 128: letters, digits and symbols |
| Length | EAN-13 / UPC-A: fixed 13 / 12 digits | Code 128: variable (up to 40 in CardDeck) |
| Density | Code 39: wider for the same text | Code 128: more compact |
| Check | Code 39: check optional | Code 128: mandatory modulo-103 check |
| Registration | EAN-13 / UPC-A: GS1 numbers for retail | Code 128: none needed for internal use |