Allin1Tool
Image ToolsRuns in your browser

Barcode Generator

Encode Code 128, EAN-13, UPC-A or Code 39 with automatic check digits, input validation and PNG or SVG export.

Share:

Barcode Generator workspace

Settings

Any printable ASCII. The code set (A/B/C) and the mod-103 check character are chosen automatically.

Narrowest bar. Retail scanners want at least 2 px on screen.

Preview

Shown at full export resolution.

Processed entirely in this browser — nothing is uploaded.

Using Barcode Generator

  1. Choose a symbology; the hint under the input states exactly what that standard accepts.

  2. Type the value. Invalid input is rejected with the reason, such as the digit count a standard needs.

  3. Read the encoded value shown back to you, including any check digit that was added for you.

  4. Set the module width and bar height, and decide whether to print the human-readable line.

  5. Download as PNG, or as SVG for print work at any size.

Each symbology is encoded from its own specification, including Code 128 code-set switching, the L, G and R parity tables that carry the leading digit of an EAN-13, and the required quiet zones. Those margins are included in the exported width, so pasting the file into a layout cannot lose them.

How a Barcode Encodes a Number

Four symbologies are implemented here from their specifications: Code 128, EAN-13, UPC-A and Code 39. Each has its own alphabet, check arithmetic and margin requirement, and picking the wrong one is the first reason a barcode fails at the till.

Code 128 packs digits two at a time

Code 128 covers all 128 ASCII characters using three overlapping code sets. Set A holds the control characters and upper case, set B holds upper and lower case, and set C encodes a pair of digits in a single symbol, doubling the density of numeric data. The starting set is chosen from your data and the encoder switches mid-string wherever switching pays: a run of six or more digits, or four at either end, moves into set C and shifts back when letters resume.

Every Code 128 symbol also carries a check character the scanner verifies before reporting a read. It is a weighted sum — the start value, plus each data value multiplied by its position counting from one, all taken modulo 103. A conforming scanner that computes a different value stays silent rather than returning wrong data.

EAN-13 hides a digit in the parity

An EAN-13 symbol is 95 modules wide and draws only twelve digits, six either side of the centre guard. The thirteenth — the first digit you typed — appears nowhere in the bars.

It is carried by the encoding chosen for the left-hand six. Each digit has three patterns, called L and G on the left and R on the right, and which of the six left positions use G rather than L forms one of ten fixed parity sequences that tells the scanner the leading digit. Hence that digit prints outside the symbol, in the margin, rather than under the bars.

The check digit, worked through

EAN-13 and UPC-A share a mod-10 check digit. Reading the payload from the right, multiply alternate digits by three, add everything up, then subtract the total from the next multiple of ten.

Take 590123412345. Counting from the right, the digits that get tripled are 5, 3, 1, 3, 1 and 9, which sum to 22 and become 66. The remaining digits — 4, 2, 4, 2, 0 and 5 — add up to 17. The total is 83, the next multiple of ten is 90, so the check digit is 7 and the full code is 5901234123457.

Enter twelve digits and that 7 is calculated and appended, with a note saying so. Enter all thirteen and it is verified instead, and a mismatch is rejected along with the digit it should have been. A wrong check digit is worse than no barcode: it prints, it scans, and it reports a product that is not yours.

UPC-A, and Code 39

UPC-A takes eleven or twelve digits. A leading zero is prefixed internally and the identical 95-module layout is generated, which is how retail scanners treat the two standards. Its outer digits print at the sides, and the guard bars drop below the digit line so the eye finds the groups.

Code 39 encodes 44 characters — the digits, A to Z, space, and the symbols hyphen, period, dollar, slash, plus and percent — each as nine elements of which three are wide, framed by an asterisk at both ends, with the wide element three times the narrow one. It has no check digit, no lower case, and runs about three times longer than Code 128 for identical content. Choose it when a legacy system demands it.

Margins, module width and failures

Every symbol ships with the blank margin its specification requires, including the asymmetric eleven-and-seven modules of EAN-13, counted into the exported width so a layout cannot lose it. Module width sets the narrowest bar in pixels; two to three is a sane floor on screen, and for print the SVG carries no resolution of its own.

When a scanner refuses, the cause is usually a cropped margin, non-uniform scaling that breaks the bar ratios, a print too small for the optics, or weak contrast. It will not be an impossible pattern, since input is validated per symbology and rejected in plain language instead. For two-dimensional codes, use QR Generator.

Frequently asked

Do I have to work out the check digit myself?

No. Enter 12 digits for EAN-13 or 11 for UPC-A and the mod-10 check digit is calculated and appended, with a note telling you which digit was added. Code 128 gets its mod-103 check character automatically.

What happens if I type all 13 digits and one is wrong?

The value is rejected and you are told which final digit the first twelve actually require. A barcode with an invalid check digit is worse than none, because it scans cleanly and reports the wrong product.

How does EAN-13 fit 13 digits into 12 positions?

It does not draw the first digit at all. The six left-hand digits are encoded with one of two patterns each, and the sequence of choices identifies the leading digit, which is why that digit prints outside the bars.

Which symbology should I pick?

Code 128 for general alphanumeric data, EAN-13 or UPC-A for retail products, and Code 39 only when a legacy system demands it, since it carries no check digit and produces a symbol around three times longer.