Barcode Generator
Create and download barcodes as PNG — Code 128, EAN-13, UPC-A, Code 39 and more — with the check digits computed correctly.
An EAN-13 barcode has 13 digits and only 12 of them are drawn
Pick EAN-13 above and count the stripes. Every one is built from a fixed grid of narrow bands called modules, and the layout never varies: 3 modules of start guard, six digits at 7 modules each, a 5-module centre guard, six more digits, 3 modules of end guard. Six plus six is 12. The thirteenth digit has nowhere to go.
| Section | Pattern | Modules |
|---|---|---|
| Start guard | 101 | 3 |
| Left six digits | L or G, 7 each | 42 |
| Centre guard | 01010 | 5 |
| Right six digits | R, 7 each | 42 |
| End guard | 101 | 3 |
| Total | 11 guard + 84 data | 95 |
It is carried by a choice instead. Each of the six left-hand digits can be drawn with one of two 7-module patterns, called L and G, and which of the ten possible L/G sequences appears is what spells out the first digit. Encoding the same twelve trailing digits under all ten leading digits gives ten different barcodes, every one exactly 95 modules wide. Changing only the leading digit rewrites 11 modules, all of them in the left half — the right half comes out byte-identical. So a scanner reads the first digit by noticing the shape of the other six.
The parity is also why the label scans upside down
The L and G patterns are not arbitrary. Every L pattern contains an odd number of dark modules and every G pattern an even number, which is what makes them tellable apart at all. The right-hand patterns are the exact photographic negative of L, so they come out even too.
| Digit | L (odd) | Dark | G (even) | Dark | R (even) | Dark |
|---|---|---|---|---|---|---|
| 0 | 0001101 | 3 | 0100111 | 4 | 1110010 | 4 |
| 1 | 0011001 | 3 | 0110011 | 4 | 1100110 | 4 |
| 2 | 0010011 | 3 | 0011011 | 4 | 1101100 | 4 |
| 3 | 0111101 | 5 | 0100001 | 2 | 1000010 | 2 |
| 4 | 0100011 | 3 | 0011101 | 4 | 1011100 | 4 |
Two more constraints finish the job. Every left-half digit opens with a space and closes with a bar; every right-half digit does the reverse. A scanner dragged across the label backwards sees right-half patterns where it expected left-half ones, notices immediately, and reverses the reading. No orientation mark is needed, because the encoding itself is asymmetric. And every one of the thirty patterns is exactly 7 modules holding two bars and two spaces, so the scanner always knows where one digit ends and the next begins.
Which is why a UPC-A label and an EAN-13 label can be the same label
Of the 64 possible six-long L/G sequences, EAN-13 uses 10 and leaves 54 spare. The one assigned to leading digit 0 is LLLLLL — no G patterns at all — which is exactly the fixed layout UPC-A uses for its twelve digits. So a twelve-digit UPC-A code and the thirteen-digit EAN-13 code formed by putting a zero in front of it produce an identical pattern of bars. Checked on 300 codes as well as the sample below, the two encoders agree module for module every time.
| Encoded as | Code | Left-half patterns | Modules |
|---|---|---|---|
| UPC-A | 036000291452 | LLLLLL | 95 |
| EAN-13 | 0036000291452 | LLLLLL | 95 |
That is not a compatibility hack bolted on afterwards. EAN-13 was designed with the zero slot reserved so that North American labels already printed and already in shops would keep scanning. One barcode, two names, no reprinting — and it is the reason the format above offers UPC-A and EAN-13 as separate choices that quietly produce the same image when the leading digit is zero.
How to use
- Pick the barcode symbology.
- Enter the data — the check digit is calculated for you.
- Download at a size the scanner can read.
- Test with a real scanner before printing a run.
Frequently asked questions
Which symbology should I use?
Code 128 for general purposes — it encodes any ASCII character densely and is the usual choice for internal labelling and logistics. EAN-13 and UPC-A are for retail products and require a registered company prefix. Code 39 is older and less dense, and survives mainly in existing systems.
What is a check digit?
A digit computed from the others so a scanner can detect a misread. EAN-13 and UPC-A both require one, calculated by a weighted sum, and it is why entering 12 digits produces a 13-digit code. A barcode with the wrong check digit will simply be rejected.
Can I make my own retail barcodes?
Not legitimately. Retail EAN and UPC numbers are issued through GS1 against a registered company prefix, and inventing one risks colliding with a real product. For internal use, where the number never leaves your own system, Code 128 with your own numbering is fine.
Why will my barcode not scan?
Usually size, contrast or the quiet zone. Printing too small makes the narrow bars unreadable, low contrast defeats the scanner, and the blank margin either side is required rather than decorative. Scaling a barcode non-proportionally also breaks it.
Does the human-readable text matter?
Yes, more than it looks. It lets a person key the number in when the scan fails, which happens regularly at a till. Removing it to save space is a false economy anywhere a human might need to read it.
Should I use a QR code instead?
For anything a phone will scan, usually yes — QR codes hold far more data, scan from any angle and tolerate damage. Linear barcodes remain standard in retail and logistics because the installed base of scanners is enormous, not because they are better.
🔒 This tool runs entirely in your browser. Nothing you enter is uploaded, logged, or stored.