Barcode Generator (Code 128)

Type a stock code, an order number or any short text. You get a Code 128 barcode, packed as narrow as the standard allows, ready to download as SVG or PNG.

How it works

Code 128 is the barcode most shipping labels, warehouse shelves and asset tags use. It can hold letters, digits and symbols, and almost every handheld scanner reads it.

It has code sets. Set B stores one character in each bar pattern. Set C stores two digits in each pattern, so a run of digits takes half the space. This page switches to set C wherever a run of digits is long enough to pay for the switch, and stays in B elsewhere, so you never have to choose.

Every code ends with a check symbol, worked out from the others, that lets the scanner catch a misread. The drawing keeps 10 modules of white space on each side, the quiet zone a scanner needs to find where the code starts.

How to use it

  1. 1 Type the text or number the barcode should hold.
  2. 2 Leave "Print the text under the bars" ticked, unless the label prints the text elsewhere.
  3. 3 Scan the barcode on screen with your scanner or a phone app to check it.
  4. 4 Download it as SVG for label software and print, or as PNG for documents.

Good to know

  • Codes made only of digits come out shortest, because every pair of digits shares one bar pattern.
  • Keep codes short. Up to about 20 characters fits most labels; long codes need a wide label or very thin bars.
  • Print in black on white. Coloured bars and dark backgrounds are a common reason a scanner gives up.
  • Leave the white margins on both sides when you place the barcode on a label.

Browser support

  • Chrome 94 and later
  • Firefox 93 and later
  • Safari 16.4 and later
  • Edge 94 and later

These are the oldest versions with everything the tool uses. They are worked out from the tool itself, so they change when it does.

Version numbers checked on 2026-09-04.

Barcoding order numbers for a small warehouse, and why digits matter

Picture a small online shop that packs a few hundred orders a week. Each order has a number such as ORDER20240001, and the packer wants to scan it from the packing slip instead of typing it. Code 128 is the natural choice: every common scanner reads it, and it holds both letters and digits. The question is how wide the barcode will be on a slip that has little spare room.

Code 128 measures width in modules, the thinnest bar or space. In code set B, each character is one 11-module pattern. Written entirely in set B, ORDER20240001 is 13 characters, plus a start pattern, a check pattern and a 13-module stop pattern, plus 10 modules of quiet zone each side: 198 modules in all. This page sees that the last eight characters are digits. It writes ORDER in set B, switches to set C, and packs 20240001 as four pairs: 20, 24, 00, 01. The result is 165 modules, about 17% narrower.

Narrower matters because the scanner needs each bar to be wide enough to see. At 0.33 mm per module, a common size for label printers, 165 modules print at about 54 mm wide, while 198 would need 65 mm. On a slip with a 60 mm space, only the packed version fits at that bar size. The shop could also drop the word ORDER entirely: a code of digits only, such as 0123456789, is all set C and needs just 110 modules.

The packer downloads the SVG and adds it to the slip template. Because the file is one unit per module, the label software can scale it to exactly 0.33 mm per module without blurring the edges. They print a test slip and scan it with the handheld scanner from different angles before switching the whole workflow over.

This tool has limits. It makes Code 128 only, which is right for internal labels but not for retail products, where tills expect EAN-13 or UPC-A with a GS1 number. It accepts printable ASCII and nothing else, so no accents, tabs or the special FNC codes that GS1-128 shipping labels use. Codes longer than 80 characters are refused, because they print too wide for most labels. And it cannot promise that a code prints well: bars printed too thin, too faint or on glossy stock can fail on any scanner.

Frequently asked questions

Can I use this barcode on products sold in shops?

Not for the till. Shops scan EAN-13 or UPC-A barcodes with a number registered to your company through GS1. Code 128 is for your own use: stock, shipping, assets and documents.

Why does the code switch code sets?

Code set C stores two digits per bar pattern, so it halves the width of a run of digits. Switching costs one pattern, so the page only switches for a run of four digits at the start or end, or six in the middle.

Which characters can it hold?

Letters, digits, spaces and the symbols on a standard keyboard: the printable ASCII characters. Accented letters, emoji, tabs and line breaks are refused with a message, because Code 128 cannot store them directly.

Is my text uploaded?

No. The barcode is made by JavaScript in this tab, and nothing you type is sent or stored.

Related tools

Your files are processed on your device and are not uploaded. You can verify this in your browser’s developer tools under the Network tab.