Used by 700,000+ people
Free Code 128 barcode generator.
Code 128 encodes part numbers, serial numbers and other mixed text in a compact linear barcode. Enter your data; the generator picks the code sets and adds the check character.
How to create a Code 128 barcode
-
01
Enter the data exactly as it must scan
Type the full string, including any prefix your label format requires, such as
Pbefore a part number. Start, stop, check and code-set characters are added for you; the text line shows only your data. -
02
Match the module width to your printer
Set Resolution (dpi) to match your printer and the module width, in millimetres, to whole printer dots: at 300 dpi, 0.3387 mm (4 dots), not 0.339 mm.
-
03
Download PNG and keep the quiet zones clear
Download PNG rather than JPG and place it at 100%. The image ends at the outer bars, so leave at least 10 modules and 6.35 mm clear on both sides.
Code 128: one linear barcode for letters, digits and symbols
Code 128 is a linear barcode for the full ASCII set: letters in both cases, digits, punctuation, space and control characters. ISO/IEC 15417 specifies it. Code set C packs digits in pairs, and every symbol carries a mandatory check character. Use it for your own part numbers, serial numbers and asset tags; TEC-IT's Galia, VDA 4994, GM 1724 and Odette OTL 3 templates print it too. GS1 data, such as the Serial Shipping Container Code (SSCC), belongs in GS1-128 rather than plain Code 128.
Where Code 128 is used: transport labels, asset tags, parcels
TEC-IT's Odette OTL 3, Galia ETI.9, Ford GTL and Caterpillar templates print part number, quantity and supplier code as separate Code 128 symbols. A data identifier (DI) leads the value: P1230545, Q210000. In TEC-IT's GM 1724 and VW GTL templates, the package license plate starts with 1J on single packages, 6J on master labels and 5J on mixed loads.
TEC-IT's asset templates fit a 5.3 mm high Code 128 on a 38 × 13 mm thermal-transfer label. DPD's parcel code and the Health Industry Bar Code (HIBC) formats LIC 128 and PAS 128 are based on Code 128. Scanners set to autodiscriminate tell Code 128 apart from Code 39, Interleaved 2 of 5 and EAN/UPC.
Digit pairs shorten the code, two checks catch misreads
Code set C stores two digits in one 11-module character. TEC-IT's VDA 4994 sample license plate, 1JUN987654321000123456, needs 189 modules instead of 277 in code set B alone. At the A5 template's 0.510 mm, that is 96.4 mm instead of 141.3 mm.
Each character checks itself, because its bars always add up to an even number of modules, and the mod 103 check character covers the whole symbol. A misread character fails these checks instead of reaching your system. The reference decode algorithm also checks each character's total bar width, so ink spread that widens the bars lowers decodability.
Image formats and software for larger volumes
The online generator downloads GIF, PNG and JPG; with a plan, you also get SVG vector files. A PNG made at the printer's resolution, with a module width of whole dots, keeps Code 128's 1:2:3:4 bar widths on whole pixels.
TEC-IT's Barcode Studio turns CSV lists of part numbers or serial-number series into Code 128 symbols, and TBarCode Office links a Code 128 to an Excel cell. TBarCode SDK builds Code 128 into .NET and other Windows applications. TBarCode SDK and Barcode Studio switch code sets automatically and can force set A, B or C if a specification requires it.
Code 128 at a glance
- Type
- Linear (1D), continuous, variable length, reads in both directions
- Specification
- ISO/IEC 15417; USS Code 128 (Uniform Symbology Specification) is identical
- Character set
- ASCII 0–127; bytes 128–255 (Latin-1) through FNC4
- Code sets
- A: ASCII 0–95, control characters
B: ASCII 32–127, lower case
C: digit pairs 00–99 - Symbol character
- 11 modules: 3 bars, 3 spaces, each 1–4 modules; stop 13 modules
- Symbol width
- 11 modules per character plus 35 for start, check and stop
- Check character
- Mandatory, modulo 103; not printed, not output by the scanner
- Module width (X)
- At least 0.19 mm (TEC-IT); label specifications set their own
- Quiet zone
- 10X left and right, and at least 6.35 mm (¼ in) per TEC-IT
- Length
- Variable; the 48-character limit belongs to GS1-128
How the generator encodes ABC-abc-1234
The generator picks the start character and code sets that need the fewest symbol characters. Code set B takes the letters and hyphens; code set C stores the closing digits as the pairs 12 and 34.
| Symbol character | Value | Weight | Value × weight |
|---|---|---|---|
| Start B | 104 | 1 | 104 |
A | 33 | 1 | 33 |
B | 34 | 2 | 68 |
C | 35 | 3 | 105 |
- | 13 | 4 | 52 |
a | 65 | 5 | 325 |
b | 66 | 6 | 396 |
c | 67 | 7 | 469 |
- | 13 | 8 | 104 |
| Code C | 99 | 9 | 891 |
12 | 12 | 10 | 120 |
34 | 34 | 11 | 374 |
| Sum | 3041 |
3041 = 29 × 103 + 54, so the check value is 54. The check character sits before the stop.
Thirteen characters of 11 modules plus the 13-module stop make 156 modules. At 0.254 mm per module that is 39.6 mm, plus 6.35 mm of quiet zone per side.
Code 128 print settings: module width, quiet zone, height
- Module width. At least 0.19 mm per TEC-IT's reference; TEC-IT's Code 128 templates set 0.254–0.700 mm where they fix it. Choose whole printer dots, above all on low-resolution thermal-transfer printers.
- Quiet zone. 10 modules on each side, but no less than 6.35 mm: at 0.339 mm, 10 modules are only 3.39 mm.
- Height. TEC-IT's reference sets none for Code 128; follow your label specification. TEC-IT's templates use 13 mm for the Caterpillar part number and 20 mm for the VDA 4994 A5 license plate.
- Bar gain. Compensate ink spread with bar width reduction. TEC-IT's sample values: about 100 µm for flexographic, 50 µm for intaglio, 30 µm for offset printing.
- Verification. Grade print quality with an ISO/IEC 15416 verifier, the method the GS1 General Specifications name for Code 128.
| Printer resolution | One dot | Module widths in whole dots |
|---|---|---|
| 200 dpi | 0.127 mm | 0.254 mm (2 dots), 0.381 mm (3) |
| 300 dpi | 0.0847 mm | 0.254 mm (3 dots), 0.3387 mm (4), 0.4233 mm (5) |
| 600 dpi | 0.0423 mm | 0.2117 mm (5 dots), 0.254 mm (6), 0.3387 mm (8) |
TEC-IT's Galia and Odette OTL 3 templates use 0.339 mm (about 4 dots at 300 dpi), its Ford GTL templates 0.423 mm (about 5 dots).
Code 128 mistakes and how to avoid them
- Encoding GS1 data as plain Code 128. Without the function character FNC1 after the start character, a symbol is never GS1-128, so
(01)and the digits arrive as plain text. Use the GS1-128 generator and leave out the parentheses. - Fixing code set B for long numbers. Each digit then takes a full character: an 18-digit serial number needs 233 modules instead of 134. Let the encoder switch to code set C unless a specification fixes the set.
- Squeezing long data into a fixed box. The module width shrinks as the data grows and can drop below 0.19 mm. Shorten the data or use Data Matrix.
- Resizing or compressing the image. Scaling by a non-integer factor can give bars of the same width different dot counts, distorting Code 128's four bar widths. Generate the image at its final size and save it as PNG, not JPG.
- Appending a check digit by hand. The generator adds the mod 103 check character itself; an extra digit becomes data, and the scanner outputs it.
Code 128 compared with related barcodes
Code 128 with FNC1 after the start character and GS1 Application Identifiers. Use it for GS1 data such as the SSCC; it is capped at 48 data characters and 165.10 mm.
Digits, upper-case letters and seven symbols, 43 characters in all, with no check character by default. Lower case needs Code 39 Extended, which TEC-IT's reference calls rarely used because Code 128 compresses much better.
The same 43 characters as Code 39 plus two check characters (modulo 47). Full ASCII needs Code 93 Extended, while Code 128 encodes it directly.
Also stores digits in pairs, but only digits, only an even number of them, and without a check digit by default.
A 2D code for large data on small items, up to 2,355 alphanumeric characters. On TEC-IT's VDA 4994 templates and its GM 1724 templates since 2018, Data Matrix holds many label fields in one symbol, Code 128 only the license plate.
Frequently asked questions
Learn more about Code 128.
What characters can a Code 128 barcode encode?
What is the difference between Code 128 A, B and C?
How is the Code 128 check digit calculated?
How long can a Code 128 barcode be?
Is Code 128 the same as GS1-128?
More resources
Code-128, GS1-128 Barcode Symbology
Code 128 is a barcode symbology and also a subject to the standards of the GS1 Organization. The high data density of this barcode enables many possible…
ProductTBarCode SDK
The developer package for Windows: .NET, OCX and DLL components generate and print 100+ barcode symbologies from your applications.
ProductBarcode Studio
100+ barcode types, a live quality check and batch export.
ProductTBarCode Office
Add compliant barcodes to documents, mail merges and spreadsheets.