EAN Check.comEAN Check.com

Code 128 Barcode Generator

Turn a serial number, SKU, bin location or any short text into a Code 128 barcode and download it as SVG, PNG, EPS or PDF. Upper and lower case, digits and symbols all work, and long runs of digits are packed in pairs to keep the barcode short.

By The eancheck teamPublished

What Code 128 is

Code 128 is the general-purpose barcode of shipping and inventory. It encodes any printable ASCII text, so it carries serial numbers, SKUs, order numbers, bin locations and tracking codes that mix letters and digits. Computer Identics Corporation introduced it in 1981, and it is standardised as ISO/IEC 15417. For products sold in shops, use a UPC-A or an EAN-13 instead.

It is popular because it is dense and safe. Each character takes 11 modules, a run of digits packs two to a character, and a mandatory check character catches misreads. Courier labels, warehouse shelf and bin labels, and many hospital wristbands use it. Want the bin name rather than the code under the bars? Switch the text line to your own words in More settings, or hide it.

Code sets A, B and C

Code 128 has three character sets and can switch between them in the middle of a barcode. You do not need to pick one; the generator chooses for each part of your text whichever makes the barcode shortest.

Code setEncodesUsed for
ACapitals, digits, punctuation and control charactersData with tabs or other control codes
BCapitals, lower case, digits and punctuationOrdinary text such as Bin A3/shelf 2
CPairs of digits, 00 to 99Long numbers, at half the width

Code set C is why a 16-digit number makes a Code 128 no wider than 8 letters. Each pair of digits takes one character instead of two, so 0123456789012345 and ABCDEFGH both come to 143 modules, 47.2 mm at X 0.33 mm. Numbers are cheap in Code 128; letters cost a full character each. A mix gains from short digit runs too: ABC-1234 is 43.6 mm because its four digits pack into two pairs.

How wide and how tall

Code 128 has no fixed size. The width depends on the text and on X, the width of the narrowest bar. The table shows real widths from this generator at X 0.33 mm, including the 10-module quiet zones on each side.

TextWidth with quiet zones
1234567832.7 mm
ABC-123443.6 mm
012345678901234547.2 mm
SN-2026-0041761.7 mm
PALLET 0042 BAY 779.9 mm

To check your own text before you design the label, type it below and read its width at three bar widths.

How wide will my Code 128 be?

Digits in pairs are packed twice as tightly, so long numbers stay short. Mixed text costs one symbol per character.

If a barcode is too wide for your label, lower X before you shorten the bars. X 0.25 mm is about 10 mils and exactly 2 dots on a 203 dpi printer; at 0.19 mm, the smallest this tool allows, you need a sharp printer and a good scanner. US specifications often give X in mils, and More settings switches the tool to mils or inches.

A good rule of thumb for bar height, taken from the Code 39 standard ISO/IEC 16388, is 15% of the barcode's width without its quiet zones, and at least 5 mm. That lets a scanner line cross every bar even when the label is held at an angle. On a GS1 logistics label, the GS1 General Specifications ask for 31.75 mm. Shelf-edge and bin labels often run vertically; rotate the barcode by 90° in More settings rather than turning the label file afterwards.

Printing on a label printer, and why fonts fail

Most Code 128 labels come off a thermal printer, and a thermal printer works in whole dots: 0.125 mm at 203 dpi and 0.085 mm at 300 dpi. A bar that falls between dots prints a dot too wide or too narrow. Choose Label printer under Printing on, pick your printer's dpi, and the generator snaps every bar to whole dots, for example 0.254 mm (3 dots) or 0.339 mm (4 dots) on a 300 dpi printer. Download the PNG and print it at 100%, with no scaling or fit to page.

Not sure the printer kept the size? Print test page in the download bar makes a PDF with the barcode, a 100 mm ruler and a 50 mm square. Print it at 100% and measure the ruler with a real one.

If you made the labels with a barcode font in Excel or Word, the font is the likely reason they do not scan. It draws bars for the characters you type but leaves out the start, check and stop characters that every Code 128 needs. Insert the barcode as an image instead: one PNG or SVG from here, or a whole column at once in bulk mode, as a ZIP or a label sheet.

Code 128 and GS1-128

GS1-128 is not a different barcode. It is Code 128 with an FNC1 character placed right after the start pattern, which tells the scanner that the data follows GS1 rules: numbers in brackets called Application Identifiers, each followed by a value. (01)09506000134352(17)271231(10)ABC123 carries a GTIN, an expiry date of 31 December 2027 and a batch. Pallet labels and food and pharmaceutical shipping labels use it. Older documents call it UCC-128 or EAN-128.

Use plain Code 128, as this page makes, for your own internal codes. If a customer or retailer asks for a GS1 logistics label, the data has to follow the AI rules; you can check a string with the GS1-128 parser, or a whole column of them with the GS1-128 bulk parser. For small items the same data fits in a GS1 DataMatrix on the Data Matrix page.

When a Code 128 does not scan

Besides a missing quiet zone, a font that leaves out the check character and bars that fall between printer dots, two causes are specific to the data you type.

The text has characters the generator cannot hold

Accented letters such as é, curly quotes pasted from a word processor, and emoji are not printable ASCII. The generator stops on them and names the character, so you can replace it before printing. The standard can carry accented letters through a special FNC4 character, but scanner support for it varies, so the generator keeps to plain ASCII.

The barcode is too long for the label

A 30-character Code 128 at a sensible X is wider than most labels. Shorten the data, lower X a little, or move to Data Matrix, which holds the same text in a square a few millimetres across.

Frequently asked questions

What can I put in a Code 128 barcode?

This generator takes the 95 printable ASCII characters: digits, upper and lower case letters, the space and punctuation such as - / . : #. Smart quotes pasted from a word processor, long dashes and emoji are not ASCII, so the generator names the character and you can replace it. Up to 80 characters fit in one barcode.

Can Code 128 hold accented letters or tabs?

The standard can. ISO/IEC 15417 covers all 128 ASCII characters, with tabs and other control characters in code set A, and a special FNC4 character lets Code 128 carry byte values 128 to 255, which include letters such as é and ü. Support for FNC4 differs between scanners and systems, so this generator accepts printable ASCII only. Replace é with e, or use Data Matrix for text in other languages.

How long can a Code 128 barcode be?

The standard sets no hard limit, but every character adds width. This generator stops at 80 characters, because longer barcodes become too wide for labels and for most handheld scanners. GS1-128 has its own limit of 48 data characters. For long data, use a Data Matrix code instead: it holds far more in a small square.

What is the difference between Code 128 and GS1-128?

GS1-128 is Code 128 with a special FNC1 character at the start and data written as GS1 Application Identifiers, such as (01) for a GTIN and (17) for an expiry date. Plain Code 128 carries whatever text you give it. Older documents call GS1-128 UCC-128 or EAN-128. Use it only when a trading partner asks for GS1 logistics labels.

Why is there no check digit in the text under my barcode?

Because it is not part of your data. Code 128 always includes a check character, calculated from the data, between the data and the stop pattern. Scanners use it to catch misreads and then drop it, so by convention it is left out of the text line. You do not need to calculate it; the generator adds it to every barcode.

Which is better, Code 128 or Code 39?

Code 128 for anything new. It encodes lower case as well as capitals, always has a check character, and is shorter for the same text: about half the width for long numbers, and roughly three quarters for mixed text such as ABC-1234. Use Code 39 only when an existing system, customer or industry standard requires it.

Will a phone read a Code 128 barcode?

Usually not with the built-in camera app, which is made for QR codes. A barcode scanner app or a scanning SDK reads Code 128 well, as long as the bars are not too thin for the camera. To test a label, install a scanner app and scan the print test page.

Why does my Code 128 font not scan in Excel or Word?

Because a font only draws bars for the characters you type. A real Code 128 also needs a start character, a check character worked out from the data, and a stop character, and the font cannot add those, so the scanner rejects the code. Place a PNG or SVG from this page in the sheet as an image instead, or turn a whole column into images with bulk mode.

How do I tell a Code 128 from a Code 39?

Look at the bars. Code 39 uses only two widths, narrow and wide, and leaves a small gap between characters, so it looks evenly spaced; its text line often starts and ends with an asterisk. Code 128 uses four bar widths and runs its characters together without gaps. A scanner set to show the barcode type will tell you for certain.

What bar width should I use on a 203 dpi label printer?

A whole number of printer dots. At 203 dpi one dot is 0.125 mm, so 2 dots gives X 0.25 mm and 3 dots gives 0.375 mm. 2 dots is the smaller choice; use 3 dots for labels that get scuffed or are read from further away. Choose Label printer and 203 dpi under Printing on, and the generator snaps the bars for you.

By The eancheck teamPublished

Questions or corrections? Email the eancheck team.