Barcodes Code 128 Runs in your browser

Code 128 Barcode Generator

Encode text and numbers in a dense Code 128 barcode.

Your data is processed locally in your browser and is not uploaded to our servers.

What is Code 128?

Code 128 is a compact, high-density barcode that encodes digits, upper- and lower-case letters and common ASCII symbols. It's widely used in shipping, logistics and warehouse labels.

How to create one

Type any text or number. The generator selects the optimal Code Set (A, B or C) automatically to keep the barcode as short as possible, and shows a live preview. Download PNG or SVG, or print directly.

How it works

Code 128 packs data efficiently and includes its own checksum internally, so it's reliable even for longer strings. Numeric-only data compresses especially well using Code Set C.

Where to use it

Shipping labels, asset tags, batch and lot numbers, and internal inventory systems all rely on Code 128 for its density and flexibility.

Scanning and printing tips

Longer data makes a wider barcode — give it room and don't compress horizontally. Keep bars crisp and high-contrast, and test with your target scanner.

Limitations

Code 128 encodes standard ASCII only. Extremely long strings create very wide barcodes that may not fit your label.

Code sets A, B and C

Code 128 encodes the full 128-character ASCII set by switching between three sub-modes. The tool selects them automatically; understanding them explains why the symbol changes width as you type.

SetCoversDensityTypical use
ADigits, uppercase, punctuation, ASCII control characters1 character per symbol characterData needing control characters
BDigits, upper and lower case, all printable ASCII1 character per symbol characterMixed alphanumeric — the usual default
CDigits only, in pairs (00–99)2 digits per symbol characterLong numeric strings

Set C is the reason Code 128 is so compact for numbers: a 20-digit value takes 10 symbol characters instead of 20. Automatic mode switches into C whenever four or more digits appear together and switches back afterwards, so ABC12345678 is encoded partly in B and partly in C without you doing anything.

The practical consequence: an even number of digits encodes more compactly than an odd number. A 13-digit value cannot be fully paired, so one digit falls back to single-character encoding. If you are designing a numbering scheme and label width is tight, an even length is free efficiency.

Check character and start/stop patterns

Code 128 always carries a modulo-103 check character, and it is not optional and not shown in the human-readable text. It is calculated from the start character and the weighted positions of the data, and the encoder handles it — there is nothing to enable and nothing you can get wrong.

Every symbol also has a start character that declares the initial code set, and a stop pattern with a distinctive 13-module bar that lets a scanner tell which end it is reading from. This is why a Code 128 scans correctly upside down, and why the encoded symbol is always wider than the character count alone suggests: expect roughly 11 modules per symbol character, plus 35 for start, check and stop, plus a 10-module quiet zone at each side.

For a 10-character value that works out to about 145 modules of symbol plus 20 of quiet zone. At a 0.25 mm X-dimension that is roughly 41 mm wide — worth checking against your label before you order 10,000 of them.

Code 128 or Code 39?

Both encode alphanumeric data and both are free to use with no registration. They are not interchangeable in practice.

Code 128Code 39
Character setAll 128 ASCII, including lowercase43: digits, A–Z, space, - . $ / + %
LowercaseYesNo (only via a fragile "full ASCII" extension)
Width for 10 digitsCompact — set C pairs themRoughly 2–3× wider
Check characterAlways present, mandatoryOptional modulo-43
Self-checkingVia the check characterEach character is self-checking
GS1 supportYes — GS1-128No
Older/industrial readersUniversally supported todaySometimes the only option on legacy kit

Choose Code 128 for anything new: inventory, asset tags, shipping references, internal SKUs. It is denser, safer and carries lowercase.

Choose Code 39 only when something you cannot change requires it — an old scanner, a military or automotive standard that specifies it, or a partner's existing label spec. Longer comparison: Code 128 vs Code 39.

Frequently asked questions

What characters does Code 128 support?

Digits, upper and lower-case letters, and standard ASCII symbols. The Code Set is chosen automatically.

Is it good for numbers?

Yes — numeric data compresses very efficiently using Code Set C, producing short barcodes.

Does it need a check digit from me?

No. Code 128 includes its own checksum internally.

Do I need to choose a code set?

No. Automatic mode switches between A, B and C as the data requires, including into C for runs of four or more digits, which halves the width of numeric sections. Set it manually only when a partner specification demands a particular set.

Why did my barcode get wider when I added one digit?

An odd digit count cannot be fully paired in set C, so one digit falls back to single-character encoding. If you control the numbering scheme, an even length is free width.

Does Code 128 need a check digit?

It always has one — a modulo-103 character calculated by the encoder and not shown in the human-readable text. There is nothing to enable.

Can I use Code 128 on retail packaging?

Not for the point-of-sale symbol, which must be a UPC or EAN. Code 128 is for internal inventory, asset tags and logistics; in its GS1-128 form it carries batch, expiry and serial data on outer cases alongside the retail symbol.

Curious how we build and check these codes? Read our methodology, and the disclaimer on what a generated barcode image is and is not.