← Code 128 Barcode Generator

Code 128 Barcode Generator: Practical Tips and Common Mistakes

Reviewed by the OnlineFree.app team · Updated

Key points

  • Code 128 encodes all ASCII characters 0–127 across subsets A, B and C, with a mod-103 checksum added automatically.
  • Subset C packs two digits per symbol character: '12345678' needs 79 modules in C versus 123 in B.
  • At the default 2 px per module the printed X-dimension is about 0.53 mm on a 96 px per inch basis.
  • The 10-module quiet zones on each side are part of the output; cropping them is a common scanning failure.
  • Generic Code 128 is not GS1-128, so Application Identifiers and SSCC labels need a GS1-compliant tool.

What the Code 128 Barcode Generator outputs

Code 128 is a variable-length linear symbology that encodes the full ASCII range 0–127 using three interchangeable subsets (A, B and C), a start character, a mod-103 checksum and a stop pattern. The Code 128 Barcode Generator turns a short ASCII string into exactly that symbol in your browser: you type the data, a live SVG preview appears, and you download it as SVG or PNG. No account, no install, and it works on a phone in the aisle.

Five controls do all the work. Data is the text itself (default ABC-1234), 'Subset' defaults to Auto, 'Module width' runs 1–6 px in 0.5 steps, 'bar height' runs 20–200 px with a 60 px default, and 'show text' toggles the human-readable caption under the bars. A readout beneath the preview reports the subset actually used, the encoded character count, the mod-103 checksum value and the total module count — the last number is what you multiply by module width to predict printed width.

Downloads come in two flavours for two jobs: SVG is vector and stays sharp at any print size, while PNG is a 2× canvas raster that is fine for screens, emails and internal web pages. Because the controls sit left of the preview, you can nudge module width and bar height and see the convergence immediately instead of re-downloading to check. Anything over 48 characters triggers a warning, and 80 characters is the hard ceiling.

Which Code 128 subset should you pick?

Leave it on Auto unless you have a specific interoperability reason not to. Auto inspects your string and selects a legal start subset: subset C when the data is all digits with an even length, subset B for mixed-case text and punctuation, and subset A when control characters are involved. The readout tells you which one it chose, so you are never guessing.

The payoff of subset C is density. Each Code 128 symbol character occupies 11 modules and the stop pattern occupies 13. Encoding the eight digits '12345678' in subset C needs start + four digit pairs + checksum + stop, which is 6 × 11 + 13 = 79 modules. The same digits forced through subset B need start + eight data characters + checksum + stop, or 10 × 11 + 13 = 123 modules — roughly 36% wider for identical information. Long order numbers, SSCC-style digit runs and date codes are all natural subset C candidates.

Two rules will reject your input rather than produce a bad symbol. Subset C only accepts even-length numeric data, so '12345' cannot be encoded in C — let Auto fall back or pad the value in your source system. Subset A and subset B are restricted to their own legal charsets, so forcing A on a string containing lowercase letters is refused. Forcing a subset is a legitimate move when a downstream legacy system expects a particular start character, but it is a decision to make deliberately, not by default.

Sizing the symbol for real printers

Module width is the single most consequential setting. Printed width equals total modules × module width, so the default 2 px/module on a CSS pixel basis — 1 px ≈ 0.265 mm at 96 px per inch — gives an X-dimension of roughly 0.53 mm. A 1 px module is about 0.265 mm, which is at the narrow end for laser and handheld scanners. GS1's General Specifications publish the nominal X-dimension ranges for GS1-128 logistics labels (see GS1 barcodes); as of 2026 those figures are the reference point to check before a large rollout, especially on thermal printers.

Bar height matters more than people expect. The 60 px default is roughly 16 mm of vertical bar, and a laser or imager has to cross the full height to decode cleanly. Taller bars tolerate scanning at an angle, curved packaging and shaky hands; the 20 px minimum is really only for tiny internal labels read by a fixed scanner at close range.

Choose the format by destination. Use SVG for anything printed — it scales without blur, and you avoid resampling artefacts that turn a 2 px module into 2.3 px of mush. Use PNG for screens and documents. If a PNG ends up in Word, Excel or a layout program, never scale it below its original size, because downscaling shrinks the X-dimension below what the viewer expects. When printing, choose 'actual size' or 100%, never 'fit to page'.

Mistakes that stop a barcode from scanning

Cropping the quiet zone is the classic failure. The generator already adds 10 modules of white space on each side of the bars, which is what the symbology requires for the scanner to find the start and stop patterns. If you trim that margin in a design tool, place the barcode against a dark background, or push it into the rounded corner of a label, the symbol can become unreadable even though the bars look perfect.

Never type a checksum yourself. The mod-103 check character is computed for you and included in the symbol; the number shown in the readout is for verification only. Similarly, watch for invisible characters. A trailing space pasted from a spreadsheet is legal ASCII 32, encodes fine in subset B, and then returns from the scanner as a value that will not match your database lookup. If you are cleaning up SKU lists, the Online Word Counter And Character Counter is a quick way to spot stray spaces and unexpected lengths before you commit to print.

Be clear about what this tool is not. It produces generic Code 128, with no FNC1 character, so it cannot generate a compliant GS1-128 label with Application Identifiers. Typing '(01)12345678901234' encodes literal parentheses as data, not an AI — the parentheses in GS1 documentation are human-readable notation only. For retail POS, SSCC or AI-based logistics labels, use a GS1-compliant generator. This tool is for internal SKUs, asset IDs, order numbers and similar plain strings.

Test-scan before you print a whole roll

Generate one label, print it at 100% on the actual printer and stock, then scan it with the actual reader at the actual distance your staff will use. Compare the decoded string against your source value character by character, because scanners do not forgive a single transposed digit the way a human reader does.

For batch work, print a test sheet covering the settings you plan to use — module width 2 and 3, subsets Auto and C, both bar heights — and scan across the sheet. Note the winning combination per label family and write it down next to the SKU convention. Labels printed at 300 dpi sometimes gain a little from 2.5 px modules, and a five-minute test is cheaper than reprinting 500 labels.

The same discipline applies to downstream use. Keep a copy of the SVG source file, record the exact data string, and re-verify important identifiers against the originating system rather than trusting a screenshot. If you need other small utilities alongside this one — text cleanup, casing for label captions, quick counts — they live with the rest of the OnlineFree.app free online tools. More background on the symbology itself is available in the Code 128 overview on Wikipedia.

Frequently asked questions

Is the Code 128 Barcode Generator free, and does it upload my data?

It is free with no signup, and the barcode is generated in your browser: the SVG preview and both download formats are produced locally, so your SKU, order number or asset ID is not sent to a server as part of encoding. Downloaded files are yours to use. Always test-scan critical labels before a large print run.

What is the difference between Code 128A, 128B and 128C?

Subset A encodes uppercase letters, digits and ASCII control characters 0–31; subset B covers ASCII 32–127 including lowercase letters and punctuation; subset C encodes numeric data two digits per symbol character, but only for even-length digit strings. Auto selection picks the legal, most compact option for your data.

How wide will my Code 128 barcode be in millimetres?

Printed width equals total modules multiplied by module width. The preview's readout gives the module count; at 2 px per module a CSS pixel is about 0.265 mm, so each module prints at roughly 0.53 mm. Ten-module quiet zones sit on both sides, so add those to your label width budget.

Can the Code 128 Barcode Generator create GS1-128 or SSCC labels?

No. It produces generic Code 128 without an FNC1 character, which the GS1-128 standard requires before Application Identifiers. Parentheses typed into the data field are encoded as literal characters, not as AI syntax. For retail POS, SSCC or AI-based logistics labels, use a GS1-compliant generator.

Why does my printed Code 128 barcode not scan?

The usual causes are a module width that is too small for the reader, a quietly cropped quiet zone, print scaling from a 'fit to page' setting, low contrast or glossy substrate, and invisible trailing spaces in the encoded data. Reprint one label at 2 or 3 px per module with full margins and rescan before changing anything else.

References

Try Code 128 Barcode Generator free — no sign-up, works in your browser
Open the tool →

More free tools

Step-by-step guides in our blog & guides.

Percentage Calculator Calcul Mensualité Crédit Immobilier LLM VRAM Calculator Medium Article Unlocker Mm To Feet And Inches Fraction Calculator Usd To Sar Converter Free Programs To Resize Images Word & Character Counter Online Free Free Qr Code Generator 1788978850636 Custom PRD build